DiactorosMessageFactory.php
2 years ago
GuzzleMessageFactory.php
6 months ago
SlimMessageFactory.php
2 years ago
GuzzleMessageFactory.php
54 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaHttp\Message\MessageFactory; |
| 4 | |
| 5 | use AmeliaVendor\GuzzleHttp\Psr7\Request; |
| 6 | use AmeliaVendor\GuzzleHttp\Psr7\Response; |
| 7 | use AmeliaHttp\Message\MessageFactory; |
| 8 | |
| 9 | /** |
| 10 | * Creates Guzzle messages. |
| 11 | * |
| 12 | * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> |
| 13 | */ |
| 14 | final class GuzzleMessageFactory implements MessageFactory |
| 15 | { |
| 16 | /** |
| 17 | * {@inheritdoc} |
| 18 | */ |
| 19 | public function createRequest( |
| 20 | $method, |
| 21 | $uri, |
| 22 | array $headers = [], |
| 23 | $body = null, |
| 24 | $protocolVersion = '1.1' |
| 25 | ) { |
| 26 | return new Request( |
| 27 | $method, |
| 28 | $uri, |
| 29 | $headers, |
| 30 | $body, |
| 31 | $protocolVersion |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * {@inheritdoc} |
| 37 | */ |
| 38 | public function createResponse( |
| 39 | $statusCode = 200, |
| 40 | $reasonPhrase = null, |
| 41 | array $headers = [], |
| 42 | $body = null, |
| 43 | $protocolVersion = '1.1' |
| 44 | ) { |
| 45 | return new Response( |
| 46 | $statusCode, |
| 47 | $headers, |
| 48 | $body, |
| 49 | $protocolVersion, |
| 50 | $reasonPhrase |
| 51 | ); |
| 52 | } |
| 53 | } |
| 54 |