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.

ClientFilter   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 132
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 43
c 1
b 0
f 0
dl 0
loc 132
ccs 44
cts 44
cp 1
rs 10
wmc 15

6 Methods

Rating   Name   Duplication   Size   Complexity  
A clientName() 0 17 3
A milliseconds() 0 10 2
A regionId() 0 24 4
A connectTimeout() 0 10 2
A retry() 0 10 2
A timeout() 0 10 2
1
<?php
2
3
namespace AlibabaCloud\Client\Filter;
4
5
use AlibabaCloud\Client\SDK;
6
use AlibabaCloud\Client\Exception\ClientException;
7
8
/**
9
 * Class ClientFilter
10
 *
11
 * @package AlibabaCloud\Client\Filter
12
 */
13
class ClientFilter
14
{
15
    /**
16
     * @param $regionId
17
     *
18
     * @return string
19
     *
20
     * @throws ClientException
21
     */
22 115
    public static function regionId($regionId)
23
    {
24 115
        if (!is_string($regionId)) {
25 4
            throw new ClientException(
26 4
                'Region ID must be a string',
27
                SDK::INVALID_ARGUMENT
28 4
            );
29
        }
30
31 111
        if ($regionId === '') {
32 4
            throw new ClientException(
33 4
                'Region ID cannot be empty',
34
                SDK::INVALID_ARGUMENT
35 4
            );
36
        }
37
38 107
        if (!preg_match("/^[a-zA-Z0-9_-]+$/", $regionId)) {
39
            throw new ClientException(
40
                'Invalid Region ID',
41
                SDK::INVALID_ARGUMENT
42
            );
43
        }
44
45
        return strtolower($regionId);
46
    }
47
48 171
    /**
49
     * @param $clientName
50 171
     *
51 5
     * @return string
52 5
     *
53
     * @throws ClientException
54 5
     */
55
    public static function clientName($clientName)
56
    {
57 166
        if (!is_string($clientName)) {
58 5
            throw new ClientException(
59 5
                'Client Name must be a string',
60
                SDK::INVALID_ARGUMENT
61 5
            );
62
        }
63
64 161
        if ($clientName === '') {
65
            throw new ClientException(
66
                'Client Name cannot be empty',
67
                SDK::INVALID_ARGUMENT
68
            );
69
        }
70
71
        return strtolower($clientName);
72
    }
73
74 9
    /**
75
     * @param $times
76 9
     *
77 2
     * @return string
78 2
     *
79
     * @throws ClientException
80 2
     */
81
    public static function retry($times)
82
    {
83 7
        if (!is_int($times)) {
84
            throw new ClientException(
85
                'Retry must be a int',
86
                SDK::INVALID_ARGUMENT
87
            );
88
        }
89
90
        return $times;
91
    }
92 70
93
    /**
94 70
     * @param $connectTimeout
95 2
     *
96 2
     * @return mixed
97
     * @throws ClientException
98 2
     */
99
    public static function connectTimeout($connectTimeout)
100
    {
101 68
        if ($connectTimeout === '') {
102
            throw new ClientException(
103
                'Connect Timeout cannot be empty',
104
                SDK::INVALID_ARGUMENT
105
            );
106
        }
107
108
        return $connectTimeout;
109
    }
110 71
111
    /**
112 71
     * @param $timeout
113 2
     *
114 2
     * @return mixed
115
     * @throws ClientException
116 2
     */
117
    public static function timeout($timeout)
118
    {
119 69
        if ($timeout === '') {
120
            throw new ClientException(
121
                'Timeout cannot be empty',
122
                SDK::INVALID_ARGUMENT
123
            );
124
        }
125
126
        return $timeout;
127
    }
128 4
129
    /**
130 4
     * @param int $Milliseconds
131 2
     *
132 2
     * @return mixed
133
     * @throws ClientException
134 2
     */
135
    public static function milliseconds($Milliseconds)
136
    {
137 2
        if (!is_int($Milliseconds)) {
0 ignored issues
show
introduced by
The condition is_int($Milliseconds) is always true.
Loading history...
138
            throw new ClientException(
139
                'Milliseconds must be int',
140
                SDK::INVALID_ARGUMENT
141
            );
142
        }
143
144
        return $Milliseconds;
145
    }
146
}
147