Micro library with PostRequestSender interface and some test doubles.
For the common cases where you do not need the complexity of the heavyweight libraries.
interface PostRequestSender {
/**
* @param string $url
* @param array<string, mixed> $fields
*/
public function post( string $url, array $fields ): PostResponse;
}$response = $requestSender->post( 'https://example.com', [ 'foo' => 'bar', 'baz' => 42 ] );
echo $response->body;
echo $response->statusCode;Adapters
GuzzlePostRequestSenderAdapter for Guzzle
Decorators
LoggingPostRequestSenderTakes aPsr\Log\LoggerInterfaceSpyPostRequestSenderTest double that records calls
Test doubles
SpyPostRequestSenderTest double that records callsStubPostRequestSenderTest double that returns a response provided in the constructor
- Ditched
ResponseInterfacein favor of a new simple value objectPostResponse
- Fixed behavior of
TestResponse::getBody
Initial release with
PostRequestSenderinterfaceSpyPostRequestSendertest double (andPostRequestvalue object)StubPostRequestSendertest doubleGuzzlePostRequestSenderimplementationLoggingPostRequestSenderdecoratorTestResponsehelper implementation or PSR7ResponseInterface

