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 ( c11e1b...0baec8 )
by Jonny
03:47
created

Response::getRedirectUrl()   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 2
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
     * Import response data
87
     *
88
     * @access public
89
     * @param  array                           $data
90
     * @return \JonnyW\PhantomJs\Http\Response
91
     */
92
    public function import(array $data)
93
    {
94
        foreach ($data as $param => $value) {
95
96
            if ($param === 'headers') {
97
                continue;
98
            }
99
100
            if (property_exists($this, $param)) {
101
                $this->$param = $value;
102
            }
103
        }
104
105
        $this->headers = array();
106
107
        if (isset($data['headers'])) {
108
            $this->setHeaders((array) $data['headers']);
109
        }
110
111
        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
    protected function setHeaders(array $headers)
122
    {
123
        foreach ($headers as $header) {
124
125
            if (isset($header['name']) && isset($header['value'])) {
126
                $this->headers[$header['name']] = $header['value'];
127
            }
128
        }
129
130
        return $this;
131
    }
132
133
    /**
134
     * Get HTTP headers array
135
     *
136
     * @access public
137
     * @return array
138
     */
139
    public function getHeaders()
140
    {
141
        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
    public function getStatus()
167
    {
168
        return (int) $this->status;
169
    }
170
171
    /**
172
     * Get page content from response
173
     *
174
     * @access public
175
     * @return string
176
     */
177
    public function getContent()
178
    {
179
        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
    public function getRedirectUrl()
211
    {
212
        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
    public function getConsole()
247
    {
248
        return $this->console;
249
    }
250
}
251