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 11

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 11
c 3
b 0
f 0
lcom 1
cbo 3
dl 0
loc 63
ccs 31
cts 31
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 26 6
A getStatusCode() 0 4 1
A getReasonPhrase() 0 4 1
A withStatus() 0 10 3
1
<?php
2
/*
3
 * This file is part of the ReCaptcha Library.
4
 *
5
 * (c) Ilya Pokamestov <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
*/
10
11
namespace DS\Library\ReCaptcha\Http;
12
13
use Psr\Http\Message\ResponseInterface;
14
15
/**
16
 * ReCaptcha library, PSR7 response representation.
17
 *
18
 * @author Ilya Pokamestov <[email protected]>
19
 *
20
 * Class Response
21
 * @package DS\Library\ReCaptcha\Http
22
 */
23
class Response extends Message implements ResponseInterface
24
{
25
    /** @var null|string */
26
    protected $reasonPhrase = '';
27
    /** @var int */
28
    protected $statusCode = 200;
29
30
    /**
31
     * @param int    $status  Status code for the response, if any.
32
     * @param array  $headers Headers for the response, if any.
33
     * @param mixed  $body    Stream body.
34
     */
35 10
    public function __construct($status = 200, array $headers = array(), $body = null)
36
    {
37 10
        $this->statusCode = (int)$status;
38 10
        if ($body) {
39 5
            $this->stream = new Stream($body);
40 5
        }
41
42 10
        foreach ($headers as $headerName => $header) {
43
            //Some HTTP clients can provide header value in array format.
44 3
            if (is_array($header)) {
45 1
                $name = $headerName;
46 1
                $value = current($header);
47 1
            } else {
48 2
                list($name, $value) = explode(':', $header);
49
            }
50
51 3
            $values = explode(';', trim($value));
52 3
            foreach ($values as $headerValue) {
53 3
                $this->withAddedHeader($name, trim($headerValue));
54 3
            }
55 10
        }
56
57 10
        if (isset(Protocol::$phrases[$this->statusCode])) {
58 10
            $this->reasonPhrase = Protocol::$phrases[$this->statusCode];
59 10
        }
60 10
    }
61
62
    /** {@inheritdoc} */
63 3
    public function getStatusCode()
64
    {
65 3
        return $this->statusCode;
66
    }
67
68
    /** {@inheritdoc} */
69 2
    public function getReasonPhrase()
70
    {
71 2
        return $this->reasonPhrase;
72
    }
73
74
    /** {@inheritdoc} */
75 1
    public function withStatus($code, $reasonPhrase = '')
76
    {
77 1
        $this->statusCode = (int)$code;
78 1
        if (!$reasonPhrase && isset(Protocol::$phrases[$this->statusCode])) {
79 1
            $reasonPhrase = Protocol::$phrases[$this->statusCode];
80 1
        }
81 1
        $this->reasonPhrase = $reasonPhrase;
82
83 1
        return $this;
84
    }
85
}
86