GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 9dc691...a1e10d )
by Benjamin
02:44
created

ResponseSender::sendHeaders()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 6.7441

Importance

Changes 0
Metric Value
cc 4
eloc 8
nc 4
nop 0
dl 0
loc 17
rs 9.2
c 0
b 0
f 0
ccs 4
cts 9
cp 0.4444
crap 6.7441
1
<?php
2
3
namespace App\Lib\Http;
4
5
use Psr\Http\Message\ResponseInterface;
6
7
class ResponseSender
8
{
9
    protected $response;
10
11 1
    public function __construct(ResponseInterface $response)
12
    {
13 1
        $this->response = $response;
14 1
    }
15
16 1
    public function sendResponse()
17
    {
18 1
        $this->sendHeaders();
19 1
        $this->sendContent();
20
21 1
        return $this;
22
    }
23
24 1
    public function sendHeaders()
25
    {
26 1
        $res = $this->response;
27
28 1
        if (headers_sent()) {
29 1
            return $this;
30
        }
31
32
        foreach ($res->getHeaders() as $name => $values) {
33
            foreach ($values as $value) {
34
                header($name.': '.$value, false, $res->getStatusCode());
35
            }
36
        }
37
38
        header(sprintf('HTTP/%s %s %s', $res->getProtocolVersion(), $res->getStatusCode(), $res->getReasonPhrase()));
39
40
        return $this;
41
    }
42
43 1
    public function sendContent()
44
    {
45 1
        echo (string) $this->response->getBody();
46
47 1
        return $this;
48
    }
49
}
50