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.

Message::withBody()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
crap 1
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\MessageInterface;
14
use Psr\Http\Message\StreamInterface;
15
16
/**
17
 * ReCaptcha library, PSR7 message implementation.
18
 *
19
 * @author Ilya Pokamestov <[email protected]>
20
 *
21
 * Class Message
22
 * @package DS\Library\ReCaptcha\Http
23
 */
24
class Message implements MessageInterface
25
{
26
    /** @var array Cached HTTP header collection with lowercase key to values */
27
    protected $headers = array();
28
    /** @var string */
29
    protected $protocol = '1.1';
30
    /** @var StreamInterface */
31
    protected $stream;
32
33
    /** {@inheritdoc} */
34 1
    public function getProtocolVersion()
35
    {
36 1
        return $this->protocol;
37
    }
38
39
    /** {@inheritdoc} */
40 2
    public function withProtocolVersion($version)
41
    {
42 2
        $this->protocol = $version;
43
44 2
        return $this;
45
    }
46
47
    /** {@inheritdoc} */
48 2
    public function getHeaders()
49
    {
50 2
        return $this->headers;
51
    }
52
53
    /** {@inheritdoc} */
54 4
    public function hasHeader($header)
55
    {
56 4
        return isset($this->headers[strtolower($header)]);
57
    }
58
59
    /** {@inheritdoc} */
60 6
    public function getHeader($header)
61
    {
62 6
        $name = strtolower($header);
63
64 6
        return isset($this->headers[$name]) ? $this->headers[$name] : array();
65
    }
66
67
    /** {@inheritdoc} */
68 6
    public function getHeaderLine($header)
69
    {
70 6
        return implode(', ', $this->getHeader($header));
71
    }
72
73
    /** {@inheritdoc} */
74 5
    public function withHeader($header, $value)
75
    {
76 5
        $header = trim($header);
77 5
        $name = strtolower($header);
78 5
        if (!is_array($value)) {
79 5
            $this->headers[$name] = array(trim($value));
80 5
        } else {
81 1
            $this->headers[$name] = array_map('trim', $value);
82
        }
83
84 5
        return $this;
85
    }
86
87
    /** {@inheritdoc} */
88 4
    public function withAddedHeader($header, $value)
89
    {
90 4
        if (!$this->hasHeader($header)) {
91 3
            return $this->withHeader($header, $value);
92
        }
93 3
        $this->headers[strtolower($header)][] = $value;
94
95 3
        return $this;
96
    }
97
98
    /** {@inheritdoc} */
99 1
    public function withoutHeader($header)
100
    {
101 1
        if ($this->hasHeader($header)) {
102 1
            $name = strtolower($header);
103 1
            unset($this->headers[$name]);
104 1
        }
105
106 1
        return $this;
107
    }
108
109
    /** {@inheritdoc} */
110 5
    public function getBody()
111
    {
112 5
        if (!$this->stream) {
113 2
            $this->stream = new Stream('');
114 2
        }
115
116 5
        return $this->stream;
117
    }
118
119
    /** {@inheritdoc} */
120 2
    public function withBody(StreamInterface $body)
121
    {
122 2
        $this->stream = $body;
123
124 2
        return $this;
125
    }
126
}
127