1 | <?php |
||
9 | abstract class AbstractHttpEmitter extends AbstractEmitter |
||
10 | { |
||
11 | 3 | public function __invoke(Throwable $throwable) : Throwable |
|
12 | { |
||
13 | 3 | $this->sendHeaders(); |
|
14 | |||
15 | 3 | return parent::__invoke($throwable); |
|
16 | } |
||
17 | |||
18 | 3 | protected function sendHeaders() |
|
19 | { |
||
20 | 3 | if (!isset($_SERVER["REQUEST_URI"]) || headers_sent()) { |
|
21 | 2 | return; |
|
22 | } |
||
23 | |||
24 | 1 | http_response_code(500); |
|
25 | |||
26 | 1 | header("Content-Type: {$this->getContentType()}"); |
|
27 | 1 | } |
|
28 | |||
29 | abstract protected function getContentType() : string; |
||
30 | } |
||
31 |