Conditions | 5 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function publish($response): void |
||
16 | { |
||
17 | $output = fopen('php://output', 'a'); |
||
18 | |||
19 | if ($response instanceof ResponseInterface) { |
||
20 | http_response_code($response->getStatusCode()); |
||
21 | |||
22 | foreach ($response->getHeaders() as $name => $values) { |
||
23 | @header($name . ': ' . $response->getHeaderLine($name)); |
||
24 | } |
||
25 | |||
26 | fwrite($output, $response->getBody()); |
||
27 | } elseif (is_scalar($response)) { |
||
28 | fwrite($output, $response); |
||
29 | } elseif ($response === null) { |
||
30 | fwrite($output, ''); |
||
31 | } else { |
||
32 | fwrite($output, json_encode($response)); |
||
33 | } |
||
34 | |||
35 | fclose($output); |
||
36 | } |
||
38 |
If you suppress an error, we recommend checking for the error condition explicitly: