Micro library with interface for sending post requests. Includes test doubles and adapters
OTHER License
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 GuzzleDecorators
LoggingPostRequestSender
Takes a Psr\Log\LoggerInterface
SpyPostRequestSender
Test double that records callsTest doubles
SpyPostRequestSender
Test double that records callsStubPostRequestSender
Test double that returns a response provided in the constructorResponseInterface
in favor of a new simple value object PostResponse
TestResponse::getBody
Initial release with
PostRequestSender
interfaceSpyPostRequestSender
test double (and PostRequest
value object)StubPostRequestSender
test doubleGuzzlePostRequestSender
implementationLoggingPostRequestSender
decoratorTestResponse
helper implementation or PSR7 ResponseInterface