Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ResponseFactory | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| createResponse | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | /** |
| 4 | * Pop PHP Framework (https://www.popphp.org/) |
| 5 | * |
| 6 | * @link https://github.com/popphp/popphp-framework |
| 7 | * @author Nick Sagona, III <dev@noladev.com> |
| 8 | * @copyright Copyright (c) 2009-2027 NOLA Interactive, LLC. |
| 9 | * @license https://www.popphp.org/license New BSD License |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * @namespace |
| 14 | */ |
| 15 | namespace Pop\Http\Factory; |
| 16 | |
| 17 | use Psr\Http\Message\ResponseFactoryInterface; |
| 18 | use Psr\Http\Message\ResponseInterface; |
| 19 | use Pop\Http\Client\Response; |
| 20 | |
| 21 | /** |
| 22 | * PSR-17 response factory class |
| 23 | * |
| 24 | * @category Pop |
| 25 | * @package Pop\Http |
| 26 | * @author Nick Sagona, III <dev@noladev.com> |
| 27 | * @copyright Copyright (c) 2009-2027 NOLA Interactive, LLC. |
| 28 | * @license https://www.popphp.org/license New BSD License |
| 29 | * @version 6.0.0 |
| 30 | */ |
| 31 | class ResponseFactory implements ResponseFactoryInterface |
| 32 | { |
| 33 | |
| 34 | /** |
| 35 | * Create a new response |
| 36 | * |
| 37 | * @param int $code |
| 38 | * @param string $reasonPhrase |
| 39 | * @return ResponseInterface |
| 40 | */ |
| 41 | public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface |
| 42 | { |
| 43 | $config = ['code' => $code]; |
| 44 | if ($reasonPhrase !== '') { |
| 45 | $config['message'] = $reasonPhrase; |
| 46 | } |
| 47 | return new Response($config); |
| 48 | } |
| 49 | |
| 50 | } |