AbstractHttpEmitter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 22
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A emit() 0 6 1
A sendHeaders() 0 10 3
getContentType() 0 1 ?
1
<?php
2
3
declare(strict_types=1);
4
5
namespace CentErr\Emitter;
6
7
use Throwable;
8
9
abstract class AbstractHttpEmitter extends AbstractEmitter
10
{
11 10
    public function emit(Throwable $exception) : void
12
    {
13 10
        $this->sendHeaders();
14
15 10
        parent::emit($exception);
16 10
    }
17
18 10
    protected function sendHeaders() : void
19
    {
20 10
        if (!isset($_SERVER["REQUEST_URI"]) || headers_sent()) {
21 7
            return;
22
        }
23
24 3
        http_response_code(500);
25
26 3
        header("Content-Type: {$this->getContentType()}");
27 3
    }
28
29
    abstract protected function getContentType() : string;
30
}
31