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   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 94.74%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 41
rs 10
c 0
b 0
f 0
ccs 18
cts 19
cp 0.9474
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A sendContent() 0 5 1
A __construct() 0 3 1
A sendResponse() 0 6 1
A sendHeaders() 0 17 4
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