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   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 73.68%

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 10
c 0
b 0
f 0
ccs 14
cts 19
cp 0.7368
wmc 7

4 Methods

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