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   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 94
rs 10
wmc 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getHeader() 0 14 4
A __construct() 0 5 1
A getBody() 0 3 1
A getHeaderLine() 0 3 1
A normalizeString() 0 3 1
A getStatusCode() 0 3 1
A getHeaders() 0 3 1
1
<?php
2
3
namespace Soheilrt\AdobeConnectClient\Client\Connection\Curl;
4
5
use Soheilrt\AdobeConnectClient\Client\Connection\ResponseInterface;
6
use Soheilrt\AdobeConnectClient\Client\Connection\StreamInterface;
7
use Soheilrt\AdobeConnectClient\Client\Traits\HttpReasonPhrase;
8
9
/**
10
 * The server response for cURL Connection.
11
 */
12
class Response implements ResponseInterface
13
{
14
    use HttpReasonPhrase;
15
16
    /**
17
     * @var int The response status code
18
     */
19
    protected $statusCode = 0;
20
21
    /**
22
     * @var array An associative array
23
     */
24
    protected $headers = [];
25
26
    /**
27
     * @var StreamInterface The response body
28
     */
29
    protected $body = null;
30
31
    /**
32
     * Create the Response.
33
     *
34
     * @param int             $statusCode The response status code
35
     * @param array           $headers    Associative array as name => value. Value is an array of strings
36
     * @param StreamInterface $body       The response body
37
     */
38
    public function __construct($statusCode, array $headers, StreamInterface $body)
39
    {
40
        $this->statusCode = intval($statusCode);
41
        $this->headers = $headers;
42
        $this->body = $body;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getStatusCode(): int
49
    {
50
        return $this->statusCode;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function getBody(): StreamInterface
57
    {
58
        return $this->body;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function getHeaders(): array
65
    {
66
        return $this->headers;
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72
    public function getHeaderLine($name): string
73
    {
74
        return implode(', ', $this->getHeader($name));
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function getHeader($name): array
81
    {
82
        if (isset($this->headers[$name])) {
83
            return $this->headers[$name];
84
        }
85
        $name = $this->normalizeString($name);
86
87
        foreach ($this->headers as $header => $value) {
88
            if ($this->normalizeString($header) === $name) {
89
                return $value;
90
            }
91
        }
92
93
        return [];
94
    }
95
96
    /**
97
     * Normalize the string to compare with others strings.
98
     *
99
     * @param string $string
100
     *
101
     * @return string
102
     */
103
    protected function normalizeString($string): string
104
    {
105
        return mb_strtolower(preg_replace('/[^a-zA-Z0-9]/', '', $string));
106
    }
107
}
108