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 ( cf8d9a...01d377 )
by Jonny
03:52
created

Response::getHeader()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 4
cp 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
3
/*
4
 * This file is part of the php-phantomjs.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
namespace JonnyW\PhantomJs\Http;
10
11
use JonnyW\PhantomJs\Procedure\OutputInterface;
12
13
/**
14
 * PHP PhantomJs
15
 *
16
 * @author Jon Wenmoth <[email protected]>
17
 */
18
class Response
19
    implements ResponseInterface, OutputInterface
20
{
21
    /**
22
     * Http headers array
23
     *
24
     * @var array
25
     * @access public
26
     */
27
    public $headers;
28
29
    /**
30
     * Response int
31
     *
32
     * @var string
33
     * @access public
34
     */
35
    public $status;
36
37
    /**
38
     * Response body
39
     *
40
     * @var string
41
     * @access public
42
     */
43
    public $content;
44
45
    /**
46
     * Response content type header
47
     *
48
     * @var string
49
     * @access public
50
     */
51
    public $contentType;
52
53
    /**
54
     * Requested URL
55
     *
56
     * @var string
57
     * @access public
58
     */
59
    public $url;
60
61
    /**
62
     * Redirected URL
63
     *
64
     * @var string
65
     * @access public
66
     */
67
    public $redirectURL;
68
69
    /**
70
     * Request time string
71
     *
72
     * @var string
73
     * @access public
74
     */
75
    public $time;
76
77
    /**
78
     * Console messages
79
     *
80
     * @var array
81
     * @access public
82
     */
83
    public $console;
84
85
    /**
86
     * Import response data
87
     *
88
     * @access public
89
     * @param  array                           $data
90
     * @return \JonnyW\PhantomJs\Http\Response
91
     */
92 26
    public function import(array $data)
93
    {
94 26
        foreach ($data as $param => $value) {
95
96 26
            if ($param === 'headers') {
97 24
                continue;
98
            }
99
100 26
            if (property_exists($this, $param)) {
101 26
                $this->$param = $value;
102 26
            }
103 26
        }
104
105 26
        $this->headers = array();
106
107 26
        if (isset($data['headers'])) {
108 24
            $this->setHeaders((array) $data['headers']);
109 24
        }
110
111 26
        return $this;
112
    }
113
114
    /**
115
     * Set headers array
116
     *
117
     * @access protected
118
     * @param  array                           $headers
119
     * @return \JonnyW\PhantomJs\Http\Response
120
     */
121 24
    protected function setHeaders(array $headers)
122
    {
123 24
        foreach ($headers as $header) {
124
125 24
            if (isset($header['name']) && isset($header['value'])) {
126 24
                $this->headers[$header['name']] = $header['value'];
127 24
            }
128 24
        }
129
130 24
        return $this;
131
    }
132
133
    /**
134
     * Get HTTP headers array
135
     *
136
     * @access public
137
     * @return array
138
     */
139 1
    public function getHeaders()
140
    {
141 1
        return (array) $this->headers;
142
    }
143
144
    /**
145
     * Get HTTP header value for code
146
     *
147
     * @access public
148
     * @param  string $code
149
     * @return mixed
150
     */
151
    public function getHeader($code)
152
    {
153
        if (isset($this->headers[$code])) {
154
            return $this->headers[$code];
155
        }
156
157
        return null;
158
    }
159
160
    /**
161
     * Get response status code
162
     *
163
     * @access public
164
     * @return integer
165
     */
166 2
    public function getStatus()
167
    {
168 2
        return (int) $this->status;
169
    }
170
171
    /**
172
     * Get page content from response
173
     *
174
     * @access public
175
     * @return string
176
     */
177 4
    public function getContent()
178
    {
179 4
        return $this->content;
180
    }
181
182
    /**
183
     * Get content type header
184
     *
185
     * @access public
186
     * @return string
187
     */
188
    public function getContentType()
189
    {
190
        return $this->contentType;
191
    }
192
193
    /**
194
     * Get request URL
195
     *
196
     * @access public
197
     * @return string
198
     */
199
    public function getUrl()
200
    {
201
        return $this->url;
202
    }
203
204
    /**
205
     * Get redirect URL (if redirected)
206
     *
207
     * @access public
208
     * @return string
209
     */
210 1
    public function getRedirectUrl()
211
    {
212 1
        return $this->redirectURL;
213
    }
214
215
    /**
216
     * Is response a redirect
217
     *  - Checks status codes
218
     *
219
     * @access public
220
     * @return boolean
221
     */
222
    public function isRedirect()
223
    {
224
        $status = $this->getStatus();
225
226
        return (bool) ($status >= 300 && $status <= 307);
227
    }
228
229
    /**
230
     * Get time string
231
     *
232
     * @access public
233
     * @return string
234
     */
235
    public function getTime()
236
    {
237
        return $this->time;
238
    }
239
240
    /**
241
     * Get console messages
242
     *
243
     * @access public
244
     * @return array
245
     */
246 2
    public function getConsole()
247
    {
248 2
        return $this->console;
249
    }
250
}
251