Total Complexity | 2 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
27 | class ResponseFactory implements ResponseFactoryInterface |
||
28 | { |
||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | 1 | public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface |
|
33 | { |
||
34 | 1 | extract(SuperGlobal::extract()); |
|
35 | |||
36 | 1 | $protocol = $server['SERVER_PROTOCOL'] ?? '1.1'; |
|
37 | 1 | $protocol = str_replace('HTTP/', '', $protocol); |
|
38 | |||
39 | 1 | $streamFactory = new streamFactory(); |
|
40 | |||
41 | 1 | $body = $streamFactory->createStream(); |
|
42 | |||
43 | 1 | return new Response( |
|
44 | 1 | $code, |
|
45 | 1 | $header, // from extract. |
|
46 | 1 | $body, |
|
47 | 1 | $protocol, |
|
48 | 1 | $reasonPhrase |
|
49 | 1 | ); |
|
50 | } |
||
51 | |||
52 | /* |
||
53 | |-------------------------------------------------------------------------- |
||
54 | | Non PSR-7 Methods. |
||
55 | |-------------------------------------------------------------------------- |
||
56 | */ |
||
57 | |||
58 | /** |
||
59 | * Create a new Response. |
||
60 | * |
||
61 | * @return ResponseInterface |
||
62 | */ |
||
63 | 1 | public static function fromNew(): ResponseInterface |
|
66 | } |
||
67 | } |
||
68 |