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 (#133)
by Jens A.
04:20
created

Response   A

Complexity

Total Complexity 21

Size/Duplication

Total Lines 233
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 233
c 0
b 0
f 0
wmc 21
lcom 1
cbo 0
ccs 43
cts 43
cp 1
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
B import() 0 21 5
A setHeaders() 0 11 4
A getHeaders() 0 4 1
A getHeader() 0 8 2
A getStatus() 0 4 1
A getContent() 0 4 1
A getContentType() 0 4 1
A getUrl() 0 4 1
A getRedirectUrl() 0 4 1
A isRedirect() 0 6 2
A getTime() 0 4 1
A getConsole() 0 4 1
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 47
    public function import(array $data)
93
    {
94 47
        foreach ($data as $param => $value) {
95
96 47
            if ($param === 'headers') {
97 30
                continue;
98
            }
99
100 45
            if (property_exists($this, $param)) {
101 45
                $this->$param = $value;
102 45
            }
103 47
        }
104
105 47
        $this->headers = array();
106
107 47
        if (isset($data['headers'])) {
108 30
            $this->setHeaders((array) $data['headers']);
109 30
        }
110
111 47
        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 30
    protected function setHeaders(array $headers)
122
    {
123 30
        foreach ($headers as $header) {
124
125 30
            if (isset($header['name']) && isset($header['value'])) {
126 30
                $this->headers[$header['name']] = $header['value'];
127 30
            }
128 30
        }
129
130 30
        return $this;
131
    }
132
133
    /**
134
     * Get HTTP headers array
135
     *
136
     * @access public
137
     * @return array
138
     */
139 2
    public function getHeaders()
140
    {
141 2
        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 2
    public function getHeader($code)
152
    {
153 2
        if (isset($this->headers[$code])) {
154 1
            return $this->headers[$code];
155
        }
156
157 1
        return null;
158
    }
159
160
    /**
161
     * Get response status code
162
     *
163
     * @access public
164
     * @return integer
165
     */
166 12
    public function getStatus()
167
    {
168 12
        return (int) $this->status;
169
    }
170
171
    /**
172
     * Get page content from response
173
     *
174
     * @access public
175
     * @return string
176
     */
177 8
    public function getContent()
178
    {
179 8
        return $this->content;
180
    }
181
182
    /**
183
     * Get content type header
184
     *
185
     * @access public
186
     * @return string
187
     */
188 1
    public function getContentType()
189
    {
190 1
        return $this->contentType;
191
    }
192
193
    /**
194
     * Get request URL
195
     *
196
     * @access public
197
     * @return string
198
     */
199 1
    public function getUrl()
200
    {
201 1
        return $this->url;
202
    }
203
204
    /**
205
     * Get redirect URL (if redirected)
206
     *
207
     * @access public
208
     * @return string
209
     */
210 2
    public function getRedirectUrl()
211
    {
212 2
        return $this->redirectURL;
213
    }
214
215
    /**
216
     * Is response a redirect
217
     *  - Checks status codes
218
     *
219
     * @access public
220
     * @return boolean
221
     */
222 9
    public function isRedirect()
223
    {
224 9
        $status = $this->getStatus();
225
226 9
        return (bool) ($status >= 300 && $status <= 307);
227
    }
228
229
    /**
230
     * Get time string
231
     *
232
     * @access public
233
     * @return string
234
     */
235 1
    public function getTime()
236
    {
237 1
        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