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 ( f47568...db5293 )
by Benjamin
03:27
created

ResponseSender::sendHeaders()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4.0218

Importance

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