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
GuzzlePostRequestSender
Adapter for Guzzle
Decorators
LoggingPostRequestSender
Takes aPsr\Log\LoggerInterface
SpyPostRequestSender
Test double that records calls
Test doubles
SpyPostRequestSender
Test double that records callsStubPostRequestSender
Test double that returns a response provided in the constructor
- Ditched
ResponseInterface
in favor of a new simple value objectPostResponse
- Fixed behavior of
TestResponse::getBody
Initial release with
PostRequestSender
interfaceSpyPostRequestSender
test double (andPostRequest
value object)StubPostRequestSender
test doubleGuzzlePostRequestSender
implementationLoggingPostRequestSender
decoratorTestResponse
helper implementation or PSR7ResponseInterface