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.

Response::setBody()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/**
4
 * eduVPN - End-user friendly VPN.
5
 *
6
 * Copyright: 2016-2017, The Commons Conservancy eduVPN Programme
7
 * SPDX-License-Identifier: AGPL-3.0+
8
 */
9
10
namespace SURFnet\VPN\Common\Http;
11
12
class Response
13
{
14
    /** @var int */
15
    private $statusCode;
16
17
    /** @var string */
18
    private $contentType;
19
20
    /** @var array */
21
    private $headers = [];
22
23
    /** @var string */
24
    private $body = null;
25
26
    public function __construct($statusCode = 200, $contentType = 'text/plain')
27
    {
28
        $this->statusCode = $statusCode;
29
        $this->contentType = $contentType;
30
    }
31
32
    public function addHeader($key, $value)
33
    {
34
        $this->headers[$key] = $value;
35
    }
36
37
    public function getHeader($key)
38
    {
39
        if (array_key_exists($key, $this->headers)) {
40
            return $this->headers[$key];
41
        }
42
    }
43
44
    public function setBody($body)
45
    {
46
        $this->body = $body;
47
    }
48
49
    public function getStatusCode()
50
    {
51
        return $this->statusCode;
52
    }
53
54
    public function getBody()
55
    {
56
        return $this->body;
57
    }
58
59
    public function send()
60
    {
61
        http_response_code($this->statusCode);
62
        foreach ($this->headers as $key => $value) {
63
            header(sprintf('%s: %s', $key, $value));
64
        }
65
        if (!is_null($this->body)) {
66
            header(sprintf('Content-Type: %s', $this->contentType));
67
            echo $this->body;
68
        }
69
    }
70
}
71