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.
Passed
Pull Request — master (#73)
by Yong
06:06
created

Filter::name()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 3
nop 1
dl 0
loc 17
ccs 10
cts 10
cp 1
crap 3
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace AlibabaCloud\Client;
4
5
use AlibabaCloud\Client\Exception\ClientException;
6
7
/**
8
 * Class Filter
9
 *
10
 * @package AlibabaCloud\Client
11
 */
12
class Filter
13
{
14
    /**
15
     * @param string $clientName
16
     *
17
     * @return string
18
     *
19
     * @throws ClientException
20
     */
21 170
    public static function clientName($clientName)
22
    {
23 170
        if (!is_string($clientName)) {
0 ignored issues
show
introduced by
The condition is_string($clientName) is always true.
Loading history...
24 5
            throw new ClientException(
25 5
                'Client Name must be a string',
26
                \ALIBABA_CLOUD_INVALID_ARGUMENT
27 5
            );
28
        }
29
30 165
        if ($clientName === '') {
31 5
            throw new ClientException(
32 5
                'Client Name cannot be empty',
33
                \ALIBABA_CLOUD_INVALID_ARGUMENT
34 5
            );
35
        }
36
37 160
        return strtolower($clientName);
38
    }
39
40
    /**
41
     * @param string $name
42
     *
43
     * @return string
44
     *
45
     * @throws ClientException
46
     */
47 164
    public static function name($name)
48
    {
49 164
        if (!is_string($name)) {
0 ignored issues
show
introduced by
The condition is_string($name) is always true.
Loading history...
50 5
            throw new ClientException(
51 5
                'Name must be a string',
52
                \ALIBABA_CLOUD_INVALID_ARGUMENT
53 5
            );
54
        }
55
56 159
        if ($name === '') {
57 5
            throw new ClientException(
58 5
                'Name cannot be empty',
59
                \ALIBABA_CLOUD_INVALID_ARGUMENT
60 5
            );
61
        }
62
63 154
        return $name;
64
    }
65
66
    /**
67
     * @param string $value
68
     *
69
     * @return string
70
     *
71
     * @throws ClientException
72
     */
73 12
    public static function value($value)
74
    {
75 12
        if (!is_numeric($value) && !is_string($value)) {
0 ignored issues
show
introduced by
The condition is_string($value) is always true.
Loading history...
76 3
            throw new ClientException(
77 3
                'Value must be a string or int',
78
                \ALIBABA_CLOUD_INVALID_ARGUMENT
79 3
            );
80
        }
81
82 9
        if ($value === '') {
83 3
            throw new ClientException(
84 3
                'Value cannot be empty',
85
                \ALIBABA_CLOUD_INVALID_ARGUMENT
86 3
            );
87
        }
88
89 6
        return $value;
90
    }
91
92
    /**
93
     * @param $accessKeyId
94
     * @param $accessKeySecret
95
     *
96
     * @return string
97
     *
98
     * @throws ClientException
99
     */
100 138
    public static function AccessKey($accessKeyId, $accessKeySecret)
101
    {
102 138
        if (is_numeric($accessKeyId)) {
103 5
            $accessKeyId = (string)$accessKeyId;
104 5
        }
105
106 138
        if (is_numeric($accessKeySecret)) {
107 5
            $accessKeySecret = (string)$accessKeySecret;
108 5
        }
109
110 138
        if (!is_string($accessKeyId)) {
111 6
            throw new ClientException(
112 6
                'AccessKey ID must be a string',
113
                \ALIBABA_CLOUD_INVALID_ARGUMENT
114 6
            );
115
        }
116
117 132
        if ($accessKeyId === '') {
118 6
            throw new ClientException(
119 6
                'AccessKey ID cannot be empty',
120
                \ALIBABA_CLOUD_INVALID_ARGUMENT
121 6
            );
122
        }
123
124 126
        if (!is_string($accessKeySecret)) {
125 6
            throw new ClientException(
126 6
                'AccessKey Secret must be a string',
127
                \ALIBABA_CLOUD_INVALID_ARGUMENT
128 6
            );
129
        }
130
131 120
        if ($accessKeySecret === '') {
132 6
            throw new ClientException(
133 6
                'AccessKey Secret cannot be empty',
134
                \ALIBABA_CLOUD_INVALID_ARGUMENT
135 6
            );
136
        }
137 114
    }
138
139
    /**
140
     * @param string $host
141
     *
142
     * @return string
143
     *
144
     * @throws ClientException
145
     */
146 43
    public static function host($host)
147
    {
148 43
        if (!is_string($host)) {
0 ignored issues
show
introduced by
The condition is_string($host) is always true.
Loading history...
149 3
            throw new ClientException(
150 3
                'Host must be a string',
151
                \ALIBABA_CLOUD_INVALID_ARGUMENT
152 3
            );
153
        }
154
155 40
        if ($host === '') {
156 3
            throw new ClientException(
157 3
                'Host cannot be empty',
158
                \ALIBABA_CLOUD_INVALID_ARGUMENT
159 3
            );
160
        }
161
162 37
        return $host;
163
    }
164
165
    /**
166
     * @param string $product
167
     *
168
     * @return string
169
     *
170
     * @throws ClientException
171
     */
172 110
    public static function product($product)
173
    {
174 110
        if (!is_string($product)) {
0 ignored issues
show
introduced by
The condition is_string($product) is always true.
Loading history...
175 6
            throw new ClientException(
176 6
                'Product must be a string',
177
                \ALIBABA_CLOUD_INVALID_ARGUMENT
178 6
            );
179
        }
180
181 104
        if ($product === '') {
182 3
            throw new ClientException(
183 3
                'Product cannot be empty',
184
                \ALIBABA_CLOUD_INVALID_ARGUMENT
185 3
            );
186
        }
187
188 101
        return $product;
189
    }
190
191
    /**
192
     * @param string $regionId
193
     *
194
     * @return string
195
     *
196
     * @throws ClientException
197
     */
198 125
    public static function regionId($regionId)
199
    {
200 125
        if (!is_string($regionId)) {
0 ignored issues
show
introduced by
The condition is_string($regionId) is always true.
Loading history...
201 4
            throw new ClientException(
202 4
                'Region ID must be a string',
203
                \ALIBABA_CLOUD_INVALID_ARGUMENT
204 4
            );
205
        }
206
207 121
        if ($regionId === '') {
208 4
            throw new ClientException(
209 4
                'Region ID cannot be empty',
210
                \ALIBABA_CLOUD_INVALID_ARGUMENT
211 4
            );
212
        }
213
214 117
        return $regionId;
215
    }
216
217
    /**
218
     * @param string $pattern
219
     *
220
     * @return string
221
     *
222
     * @throws ClientException
223
     */
224 10
    public static function pattern($pattern)
225
    {
226 10
        if (!is_string($pattern)) {
0 ignored issues
show
introduced by
The condition is_string($pattern) is always true.
Loading history...
227 1
            throw new ClientException(
228 1
                'Pattern must be a string',
229
                \ALIBABA_CLOUD_INVALID_ARGUMENT
230 1
            );
231
        }
232
233 9
        if ($pattern === '') {
234 1
            throw new ClientException(
235 1
                'Pattern cannot be empty',
236
                \ALIBABA_CLOUD_INVALID_ARGUMENT
237 1
            );
238
        }
239
240 8
        return $pattern;
241
    }
242
243
    /**
244
     * @param string $roleName
245
     *
246
     * @return string
247
     *
248
     * @throws ClientException
249
     */
250 29
    public static function roleName($roleName)
251
    {
252 29
        if (!is_string($roleName)) {
0 ignored issues
show
introduced by
The condition is_string($roleName) is always true.
Loading history...
253 2
            throw new ClientException(
254 2
                'Role Name must be a string',
255
                \ALIBABA_CLOUD_INVALID_ARGUMENT
256 2
            );
257
        }
258
259 27
        if ($roleName === '') {
260 2
            throw new ClientException(
261 2
                'Role Name cannot be empty',
262
                \ALIBABA_CLOUD_INVALID_ARGUMENT
263 2
            );
264
        }
265
266 25
        return $roleName;
267
    }
268
269
    /**
270
     * @param string $scheme
271
     *
272
     * @return string
273
     *
274
     * @throws ClientException
275
     */
276 28
    public static function scheme($scheme)
277
    {
278 28
        if (!is_string($scheme)) {
0 ignored issues
show
introduced by
The condition is_string($scheme) is always true.
Loading history...
279 1
            throw new ClientException(
280 1
                'Scheme must be a string',
281
                \ALIBABA_CLOUD_INVALID_ARGUMENT
282 1
            );
283
        }
284
285 27
        if ($scheme === '') {
286 1
            throw new ClientException(
287 1
                'Scheme cannot be empty',
288
                \ALIBABA_CLOUD_INVALID_ARGUMENT
289 1
            );
290
        }
291
292 26
        return $scheme;
293
    }
294
295
    /**
296
     * @param $format
297
     *
298
     * @return mixed
299
     * @throws ClientException
300
     */
301 15
    public static function format($format)
302
    {
303 15
        if (!is_string($format)) {
304 2
            throw new ClientException(
305 2
                'Format must be a string',
306
                \ALIBABA_CLOUD_INVALID_ARGUMENT
307 2
            );
308
        }
309
310 13
        if ($format === '') {
311 2
            throw new ClientException(
312 2
                'Format cannot be empty',
313
                \ALIBABA_CLOUD_INVALID_ARGUMENT
314 2
            );
315
        }
316
317 11
        return $format;
318
    }
319
320
    /**
321
     * @param $action
322
     *
323
     * @return mixed
324
     * @throws ClientException
325
     */
326 81
    public static function action($action)
327
    {
328 81
        if (!is_string($action)) {
329 1
            throw new ClientException(
330 1
                'Action must be a string',
331
                \ALIBABA_CLOUD_INVALID_ARGUMENT
332 1
            );
333
        }
334
335 80
        if ($action === '') {
336 1
            throw new ClientException(
337 1
                'Action cannot be empty',
338
                \ALIBABA_CLOUD_INVALID_ARGUMENT
339 1
            );
340
        }
341
342 79
        return $action;
343
    }
344
345
    /**
346
     * @param $body
347
     *
348
     * @return mixed
349
     * @throws ClientException
350
     */
351 7
    public static function body($body)
352
    {
353 7
        if (!is_string($body) && !is_numeric($body)) {
354 1
            throw new ClientException(
355 1
                'Body must be a string or int',
356
                \ALIBABA_CLOUD_INVALID_ARGUMENT
357 1
            );
358
        }
359
360 6
        if ($body === '') {
361 1
            throw new ClientException(
362 1
                'Body cannot be empty',
363
                \ALIBABA_CLOUD_INVALID_ARGUMENT
364 1
            );
365
        }
366
367 5
        return $body;
368
    }
369
370
    /**
371
     * @param $endpointType
372
     *
373
     * @return mixed
374
     * @throws ClientException
375
     */
376 8
    public static function endpointType($endpointType)
377
    {
378 8
        if (!is_string($endpointType)) {
379 1
            throw new ClientException(
380 1
                'Endpoint Type must be a string',
381
                \ALIBABA_CLOUD_INVALID_ARGUMENT
382 1
            );
383
        }
384
385 7
        if ($endpointType === '') {
386 1
            throw new ClientException(
387 1
                'Endpoint Type cannot be empty',
388
                \ALIBABA_CLOUD_INVALID_ARGUMENT
389 1
            );
390
        }
391
392 6
        return $endpointType;
393
    }
394
395
    /**
396
     * @param $method
397
     *
398
     * @return mixed
399
     * @throws ClientException
400
     */
401 73
    public static function method($method)
402
    {
403 73
        if (!is_string($method)) {
404 1
            throw new ClientException(
405 1
                'Method must be a string',
406
                \ALIBABA_CLOUD_INVALID_ARGUMENT
407 1
            );
408
        }
409
410 72
        if ($method === '') {
411 1
            throw new ClientException(
412 1
                'Method cannot be empty',
413
                \ALIBABA_CLOUD_INVALID_ARGUMENT
414 1
            );
415
        }
416
417 71
        return \strtoupper($method);
418
    }
419
420
    /**
421
     * @param $bearerToken
422
     *
423
     * @return mixed
424
     * @throws ClientException
425
     */
426 26
    public static function bearerToken($bearerToken)
427
    {
428 26
        if (!is_string($bearerToken)) {
429 2
            throw new ClientException(
430 2
                'Bearer Token must be a string',
431
                \ALIBABA_CLOUD_INVALID_ARGUMENT
432 2
            );
433
        }
434
435 24
        if ($bearerToken === '') {
436 2
            throw new ClientException(
437 2
                'Bearer Token cannot be empty',
438
                \ALIBABA_CLOUD_INVALID_ARGUMENT
439 2
            );
440
        }
441
442 22
        return $bearerToken;
443
    }
444
445
    /**
446
     * @param $publicKeyId
447
     *
448
     * @return mixed
449
     * @throws ClientException
450
     */
451 25
    public static function publicKeyId($publicKeyId)
452
    {
453 25
        if (!is_string($publicKeyId)) {
454 2
            throw new ClientException(
455 2
                'Public Key ID must be a string',
456
                \ALIBABA_CLOUD_INVALID_ARGUMENT
457 2
            );
458
        }
459
460 23
        if ($publicKeyId === '') {
461 2
            throw new ClientException(
462 2
                'Public Key ID cannot be empty',
463
                \ALIBABA_CLOUD_INVALID_ARGUMENT
464 2
            );
465
        }
466
467 21
        return $publicKeyId;
468
    }
469
470
    /**
471
     * @param $privateKeyFile
472
     *
473
     * @return mixed
474
     * @throws ClientException
475
     */
476 21
    public static function privateKeyFile($privateKeyFile)
477
    {
478 21
        if (!is_string($privateKeyFile)) {
479 2
            throw new ClientException(
480 2
                'Private Key File must be a string',
481
                \ALIBABA_CLOUD_INVALID_ARGUMENT
482 2
            );
483
        }
484
485 19
        if ($privateKeyFile === '') {
486 2
            throw new ClientException(
487 2
                'Private Key File cannot be empty',
488
                \ALIBABA_CLOUD_INVALID_ARGUMENT
489 2
            );
490
        }
491
492 17
        return $privateKeyFile;
493
    }
494
495
    /**
496
     * @param $version
497
     *
498
     * @return mixed
499
     * @throws ClientException
500
     */
501 84
    public static function version($version)
502
    {
503 84
        if (!is_string($version)) {
504 1
            throw new ClientException(
505 1
                'Version must be a string',
506
                \ALIBABA_CLOUD_INVALID_ARGUMENT
507 1
            );
508
        }
509
510 83
        if ($version === '') {
511 1
            throw new ClientException(
512 1
                'Version cannot be empty',
513
                \ALIBABA_CLOUD_INVALID_ARGUMENT
514 1
            );
515
        }
516
517 82
        return $version;
518
    }
519
520
    /**
521
     * @param $serviceCode
522
     *
523
     * @return mixed
524
     * @throws ClientException
525
     */
526 9
    public static function serviceCode($serviceCode)
527
    {
528 9
        if (!is_string($serviceCode)) {
529 1
            throw new ClientException(
530 1
                'Service Code must be a string',
531
                \ALIBABA_CLOUD_INVALID_ARGUMENT
532 1
            );
533
        }
534
535 8
        if ($serviceCode === '') {
536 1
            throw new ClientException(
537 1
                'Service Code cannot be empty',
538
                \ALIBABA_CLOUD_INVALID_ARGUMENT
539 1
            );
540
        }
541
542 7
        return $serviceCode;
543
    }
544
545
    /**
546
     * @param $connectTimeout
547
     *
548
     * @return mixed
549
     * @throws ClientException
550
     */
551 44
    public static function connectTimeout($connectTimeout)
552
    {
553 44
        if ($connectTimeout === '') {
554 1
            throw new ClientException(
555 1
                'Connect Timeout cannot be empty',
556
                \ALIBABA_CLOUD_INVALID_ARGUMENT
557 1
            );
558
        }
559
560 43
        return $connectTimeout;
561
    }
562
563
    /**
564
     * @param $timeout
565
     *
566
     * @return mixed
567
     * @throws ClientException
568
     */
569 45
    public static function timeout($timeout)
570
    {
571 45
        if ($timeout === '') {
572 1
            throw new ClientException(
573 1
                'Timeout cannot be empty',
574
                \ALIBABA_CLOUD_INVALID_ARGUMENT
575 1
            );
576
        }
577
578 44
        return $timeout;
579
    }
580
}
581