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
Pull Request — master (#172)
by Andrius
04:11
created

Response::getCookies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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
     * Session cookies
87
     *
88
     * @var array
89
     * @access public
90
     */
91
    public $cookies;
92 52
93
    /**
94 52
     * Import response data
95
     *
96 52
     * @access public
97 35
     * @param  array                           $data
98
     * @return \JonnyW\PhantomJs\Http\Response
99
     */
100 50
    public function import(array $data)
101 50
    {
102 50
        foreach ($data as $param => $value) {
103 52
104
            if ($param === 'headers') {
105 52
                continue;
106
            }
107 52
108 35
            if (property_exists($this, $param)) {
109 35
                $this->$param = $value;
110
            }
111 52
        }
112
113
        $this->headers = array();
114
115
        if (isset($data['headers'])) {
116
            $this->setHeaders((array) $data['headers']);
117
        }
118
119
        return $this;
120
    }
121 35
122
    /**
123 35
     * Set headers array
124
     *
125 35
     * @access protected
126 35
     * @param  array                           $headers
127 35
     * @return \JonnyW\PhantomJs\Http\Response
128 35
     */
129
    protected function setHeaders(array $headers)
130 35
    {
131
        foreach ($headers as $header) {
132
133
            if (isset($header['name']) && isset($header['value'])) {
134
                $this->headers[$header['name']] = $header['value'];
135
            }
136
        }
137
138
        return $this;
139 2
    }
140
141 2
    /**
142
     * Get HTTP headers array
143
     *
144
     * @access public
145
     * @return array
146
     */
147
    public function getHeaders()
148
    {
149
        return (array) $this->headers;
150
    }
151 2
152
    /**
153 2
     * Get HTTP header value for code
154 1
     *
155
     * @access public
156
     * @param  string $code
157 1
     * @return mixed
158
     */
159
    public function getHeader($code)
160
    {
161
        if (isset($this->headers[$code])) {
162
            return $this->headers[$code];
163
        }
164
165
        return null;
166 12
    }
167
168 12
    /**
169
     * Get response status code
170
     *
171
     * @access public
172
     * @return integer
173
     */
174
    public function getStatus()
175
    {
176
        return (int) $this->status;
177 10
    }
178
179 10
    /**
180
     * Get page content from response
181
     *
182
     * @access public
183
     * @return string
184
     */
185
    public function getContent()
186
    {
187
        return $this->content;
188 1
    }
189
190 1
    /**
191
     * Get content type header
192
     *
193
     * @access public
194
     * @return string
195
     */
196
    public function getContentType()
197
    {
198
        return $this->contentType;
199 1
    }
200
201 1
    /**
202
     * Get request URL
203
     *
204
     * @access public
205
     * @return string
206
     */
207
    public function getUrl()
208
    {
209
        return $this->url;
210 2
    }
211
212 2
    /**
213
     * Get redirect URL (if redirected)
214
     *
215
     * @access public
216
     * @return string
217
     */
218
    public function getRedirectUrl()
219
    {
220
        return $this->redirectURL;
221
    }
222 9
223
    /**
224 9
     * Is response a redirect
225
     *  - Checks status codes
226 9
     *
227
     * @access public
228
     * @return boolean
229
     */
230
    public function isRedirect()
231
    {
232
        $status = $this->getStatus();
233
234
        return (bool) ($status >= 300 && $status <= 307);
235 1
    }
236
237 1
    /**
238
     * Get time string
239
     *
240
     * @access public
241
     * @return string
242
     */
243
    public function getTime()
244
    {
245
        return $this->time;
246 2
    }
247
248 2
    /**
249
     * Get console messages
250
     *
251
     * @access public
252
     * @return array
253
     */
254
    public function getConsole()
255
    {
256
        return $this->console;
257
    }
258
259
    /**
260
     * Get session cookies
261
     *
262
     * @access public
263
     * @return array
264
     */
265
    public function getCookies()
266
    {
267
        return $this->cookies;
268
    }
269
}
270