fast-cgi-client
fast-cgi-client copied to clipboard
ComposesRequestContent->toString() and immutable request content
Branch started from https://github.com/hollodotme/fast-cgi-client/pull/74.
2 API improvements with a BC break:
-
AbstractRequest->setContent
is removed, making the content of a request immutable. Content can only be defined when creating the request, through the constructor. The script filename was already like this, and having both of them immutable results in a more resilient request object. -
ComposesRequestContent->getContent
renamed totoString
, see:- The old method name was confusing in the context of a request already having content, which ended up looking like: $request->getContent()->getContent();
toString
better illustrates what this method does, which is return a string representation of the request content.
- The old method name was confusing in the context of a request already having content, which ended up looking like: $request->getContent()->getContent();
It doesn't really make sense to me to have a setter for contentType
either now. With setContent
gone and the content property requiring an implementation of the interface, if someone wants to send a specific type of content, he'll have to create his own class implementing ComposesRequestContent anyway, and by doing so he'll set the content-type in there.
What do you think?