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

CaptureRequest::getType()   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 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
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
10
namespace JonnyW\PhantomJs\Http;
11
12
use JonnyW\PhantomJs\Exception\NotWritableException;
13
14
/**
15
 * PHP PhantomJs.
16
 *
17
 * @author Jon Wenmoth <[email protected]>
18
 */
19
class CaptureRequest extends AbstractRequest
20
    implements CaptureRequestInterface
21
{
22
    /**
23
     * Request type.
24
     *
25
     * @var string
26
     */
27
    protected $type;
28
29
    /**
30
     * File to save output.
31
     *
32
     * @var string
33
     */
34
    protected $outputFile;
35
36
    /**
37
     * Rect top.
38
     *
39
     * @var int
40
     */
41
    protected $rectTop;
42
43
    /**
44
     * Rect left.
45
     *
46
     * @var int
47
     */
48
    protected $rectLeft;
49
50
    /**
51
     * Rect width.
52
     *
53
     * @var int
54
     */
55
    protected $rectWidth;
56
57
    /**
58
     * Rect height.
59
     *
60
     * @var int
61
     */
62
    protected $rectHeight;
63
64
    /**
65
     * Capture Format.
66
     *
67
     * @var string
68
     */
69
    protected $format;
70
71
    /**
72
     * Capture Quality.
73
     *
74
     * @var int
75
     */
76
    protected $quality;
77
78
    /**
79
     * Internal constructor.
80
     *
81
     * @param string $url     (default: null)
82
     * @param string $method  (default: RequestInterface::METHOD_GET)
83
     * @param int    $timeout (default: 5000)
84
     *
85
     * @return \JonnyW\PhantomJs\Http\CaptureRequest
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
86
     */
87
    public function __construct($url = null, $method = RequestInterface::METHOD_GET, $timeout = 5000)
88
    {
89
        parent::__construct($url, $method, $timeout);
90
91
        $this->rectTop = 0;
92
        $this->rectLeft = 0;
93
        $this->rectWidth = 0;
94
        $this->rectHeight = 0;
95
        $this->format = 'jpeg';
96
        $this->quality = 75;
97
    }
98
99
    /**
100
     * Get request type.
101
     *
102
     * @return string
103
     */
104
    public function getType()
105
    {
106
        if (!$this->type) {
107
            return RequestInterface::REQUEST_TYPE_CAPTURE;
108
        }
109
110
        return $this->type;
111
    }
112
113
    /**
114
     * Set request type.
115
     *
116
     * @param string $type
117
     *
118
     * @return \JonnyW\PhantomJs\Http\AbstractRequest
119
     */
120
    public function setType($type)
121
    {
122
        $this->type = $type;
123
124
        return $this;
125
    }
126
127
    /**
128
     * Set viewport size.
129
     *
130
     * @param int $width
131
     * @param int $height
132
     * @param int $top    (default: 0)
133
     * @param int $left   (default: 0)
134
     *
135
     * @return \JonnyW\PhantomJs\Http\AbstractRequest
136
     */
137
    public function setCaptureDimensions($width, $height, $top = 0, $left = 0)
138
    {
139
        $this->rectWidth = (int) $width;
140
        $this->rectHeight = (int) $height;
141
        $this->rectTop = (int) $top;
142
        $this->rectLeft = (int) $left;
143
144
        return $this;
145
    }
146
147
    /**
148
     * Get rect top.
149
     *
150
     * @return int
151
     */
152
    public function getRectTop()
153
    {
154
        return (int) $this->rectTop;
155
    }
156
157
    /**
158
     * Get rect left.
159
     *
160
     * @return int
161
     */
162
    public function getRectLeft()
163
    {
164
        return (int) $this->rectLeft;
165
    }
166
167
    /**
168
     * Get rect width.
169
     *
170
     * @return int
171
     */
172
    public function getRectWidth()
173
    {
174
        return (int) $this->rectWidth;
175
    }
176
177
    /**
178
     * Get rect height.
179
     *
180
     * @return int
181
     */
182
    public function getRectHeight()
183
    {
184
        return (int) $this->rectHeight;
185
    }
186
187
    /**
188
     * Set file to save output.
189
     *
190
     * @param string $file
191
     *
192
     * @throws \JonnyW\PhantomJs\Exception\NotWritableException
193
     *
194
     * @return \JonnyW\PhantomJs\Http\CaptureRequest
195
     */
196
    public function setOutputFile($file)
197
    {
198
        if (!is_writable(dirname($file))) {
199
            throw new NotWritableException(sprintf('Output file is not writeable by PhantomJs: %s', $file));
200
        }
201
202
        $this->outputFile = $file;
203
204
        return $this;
205
    }
206
207
    /**
208
     * Get output file.
209
     *
210
     * @return string
211
     */
212
    public function getOutputFile()
213
    {
214
        return $this->outputFile;
215
    }
216
217
    /**
218
     * Get image format of the capture.
219
     *
220
     * @return string
221
     */
222
    public function getFormat()
223
    {
224
        return $this->format;
225
    }
226
227
    /**
228
     * Set image format of capture.
229
     * options: pdf, png, jpeg, bmp, ppm, gif.
230
     *
231
     * @param string $format
232
     */
233
    public function setFormat($format)
234
    {
235
        $this->format = $format;
236
237
        return $this;
238
    }
239
240
    /**
241
     * Get quality of capture.
242
     *
243
     * @return string
244
     */
245
    public function getQuality()
246
    {
247
        return $this->quality;
248
    }
249
250
    /**
251
     * Set quality of the capture.
252
     * example: 0 - 100.
253
     *
254
     * @param int $format
0 ignored issues
show
Bug introduced by
There is no parameter named $format. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
255
     */
256
    public function setQuality($quality)
257
    {
258
        $this->quality = (int) $quality;
259
260
        return $this;
261
    }
262
}
263