jeroen / post-request-sender
Micro library with interface for sending post requests. Includes test doubles and adapters
Fund package maintenance!
JeroenDeDauw
Installs: 22 245
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- psr/log: ^3|^2|^1
Requires (Dev)
- guzzlehttp/guzzle: ^7.0.1
- jeroen/psr-log-test-doubles: ^3.1.0
- phpstan/phpstan: ^1.4.3
- phpunit/phpunit: ^9.5.2
- vimeo/psalm: ^4.19.0
Suggests
- guzzlehttp/guzzle: Allows using the GuzzlePostRequestSender implementation
This package is auto-updated.
Last update: 2024-10-14 20:14:36 UTC
README
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; }
Usage
$response = $requestSender->post( 'https://example.com', [ 'foo' => 'bar', 'baz' => 42 ] ); echo $response->body; echo $response->statusCode;
Included implementations
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
Release notes
2.0.0 (2022-02-03)
- Ditched
ResponseInterface
in favor of a new simple value objectPostResponse
1.0.1 (2022-02-02)
- Fixed behavior of
TestResponse::getBody
1.0.0 (2022-01-30)
Initial release with
PostRequestSender
interfaceSpyPostRequestSender
test double (andPostRequest
value object)StubPostRequestSender
test doubleGuzzlePostRequestSender
implementationLoggingPostRequestSender
decoratorTestResponse
helper implementation or PSR7ResponseInterface