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.

ApiFilter   A
last analyzed

Complexity

Total Complexity 29

Size/Duplication

Total Lines 245
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 90
dl 0
loc 245
ccs 70
cts 70
cp 1
rs 10
c 1
b 0
f 0
wmc 29

9 Methods

Rating   Name   Duplication   Size   Complexity  
A serviceCode() 0 17 3
A endpointType() 0 17 3
A action() 0 17 3
A network() 0 24 4
A pattern() 0 17 3
A version() 0 17 3
A format() 0 17 3
A product() 0 17 3
A endpointSuffix() 0 24 4
1
<?php
2
3
namespace AlibabaCloud\Client\Filter;
4
5
use AlibabaCloud\Client\SDK;
6
use AlibabaCloud\Client\Exception\ClientException;
7
8
/**
9
 * Class ApiFilter
10
 *
11
 * @package AlibabaCloud\Client\Filter
12
 */
13
class ApiFilter
14
{
15
    /**
16
     * @param $serviceCode
17
     *
18
     * @return mixed
19
     * @throws ClientException
20
     */
21 11
    public static function serviceCode($serviceCode)
22
    {
23 11
        if (!is_string($serviceCode)) {
24 1
            throw new ClientException(
25 1
                'Service Code must be a string',
26
                SDK::INVALID_ARGUMENT
27 1
            );
28
        }
29
30 10
        if ($serviceCode === '') {
31 1
            throw new ClientException(
32 1
                'Service Code cannot be empty',
33
                SDK::INVALID_ARGUMENT
34 1
            );
35
        }
36
37 9
        return $serviceCode;
38
    }
39
40
    /**
41
     * @param $endpointType
42
     *
43
     * @return mixed
44
     * @throws ClientException
45
     */
46 9
    public static function endpointType($endpointType)
47
    {
48 9
        if (!is_string($endpointType)) {
49 1
            throw new ClientException(
50 1
                'Endpoint Type must be a string',
51
                SDK::INVALID_ARGUMENT
52 1
            );
53
        }
54
55 8
        if ($endpointType === '') {
56 1
            throw new ClientException(
57 1
                'Endpoint Type cannot be empty',
58
                SDK::INVALID_ARGUMENT
59 1
            );
60
        }
61
62 7
        return $endpointType;
63
    }
64
65
    /**
66
     * @param $action
67
     *
68
     * @return mixed
69
     * @throws ClientException
70
     */
71 70
    public static function action($action)
72
    {
73 70
        if (!is_string($action)) {
74 1
            throw new ClientException(
75 1
                'Action must be a string',
76
                SDK::INVALID_ARGUMENT
77 1
            );
78
        }
79
80 69
        if ($action === '') {
81 1
            throw new ClientException(
82 1
                'Action cannot be empty',
83
                SDK::INVALID_ARGUMENT
84 1
            );
85
        }
86
87 68
        return $action;
88
    }
89
90
    /**
91
     * @codeCoverageIgnore
92
     *
93
     * @param string $endpointSuffix
94
     *
95
     * @return mixed
96
     * @throws ClientException
97
     */
98
    public static function endpointSuffix($endpointSuffix)
99
    {
100
        if (!is_string($endpointSuffix)) {
0 ignored issues
show
introduced by
The condition is_string($endpointSuffix) is always true.
Loading history...
101
            throw new ClientException(
102
                'Endpoint Suffix must be a string',
103
                SDK::INVALID_ARGUMENT
104
            );
105
        }
106
107
        if ($endpointSuffix === '') {
108
            throw new ClientException(
109
                'Endpoint Suffix cannot be empty',
110
                SDK::INVALID_ARGUMENT
111
            );
112
        }
113
114
        if (!preg_match("/^[a-zA-Z0-9_-]+$/", $endpointSuffix)) {
115
            throw new ClientException(
116
                'Invalid Endpoint Suffix',
117
                SDK::INVALID_ARGUMENT
118
            );
119
        }
120
121
        return $endpointSuffix;
122
    }
123
124
    /**
125
     * @codeCoverageIgnore
126
     *
127
     * @param string $network
128
     *
129
     * @return mixed
130
     * @throws ClientException
131
     */
132
    public static function network($network)
133
    {
134
        if (!is_string($network)) {
0 ignored issues
show
introduced by
The condition is_string($network) is always true.
Loading history...
135
            throw new ClientException(
136
                'Network Suffix must be a string',
137
                SDK::INVALID_ARGUMENT
138
            );
139
        }
140
141
        if ($network === '') {
142
            throw new ClientException(
143
                'Network Suffix cannot be empty',
144
                SDK::INVALID_ARGUMENT
145
            );
146
        }
147
148
        if (!preg_match("/^[a-zA-Z0-9_-]+$/", $network)) {
149
            throw new ClientException(
150 74
                'Invalid Network Suffix',
151
                SDK::INVALID_ARGUMENT
152 74
            );
153 1
        }
154 1
155
        return $network;
156 1
    }
157
158
    /**
159 73
     * @param string $version
160 1
     *
161 1
     * @return mixed
162
     * @throws ClientException
163 1
     */
164
    public static function version($version)
165
    {
166 72
        if (!is_string($version)) {
0 ignored issues
show
introduced by
The condition is_string($version) is always true.
Loading history...
167
            throw new ClientException(
168
                'Version must be a string',
169
                SDK::INVALID_ARGUMENT
170
            );
171
        }
172
173
        if ($version === '') {
174
            throw new ClientException(
175 14
                'Version cannot be empty',
176
                SDK::INVALID_ARGUMENT
177 14
            );
178 1
        }
179 1
180
        return $version;
181 1
    }
182
183
    /**
184 13
     * @param $format
185 1
     *
186 1
     * @return mixed
187
     * @throws ClientException
188 1
     */
189
    public static function format($format)
190
    {
191 12
        if (!is_string($format)) {
192
            throw new ClientException(
193
                'Format must be a string',
194
                SDK::INVALID_ARGUMENT
195
            );
196
        }
197
198
        if ($format === '') {
199
            throw new ClientException(
200
                'Format cannot be empty',
201 104
                SDK::INVALID_ARGUMENT
202
            );
203 104
        }
204 6
205 6
        return \strtoupper($format);
206
    }
207 6
208
    /**
209
     * @param $product
210 98
     *
211 3
     * @return string
212 3
     *
213
     * @throws ClientException
214 3
     */
215
    public static function product($product)
216
    {
217 95
        if (!is_string($product)) {
218
            throw new ClientException(
219
                'Product must be a string',
220
                SDK::INVALID_ARGUMENT
221
            );
222
        }
223
224
        if ($product === '') {
225
            throw new ClientException(
226
                'Product cannot be empty',
227 10
                SDK::INVALID_ARGUMENT
228
            );
229 10
        }
230 1
231 1
        return $product;
232
    }
233 1
234
    /**
235
     * @param $pattern
236 9
     *
237 1
     * @return string
238 1
     *
239
     * @throws ClientException
240 1
     */
241
    public static function pattern($pattern)
242
    {
243 8
        if (!is_string($pattern)) {
244
            throw new ClientException(
245
                'Pattern must be a string',
246
                SDK::INVALID_ARGUMENT
247
            );
248
        }
249
250
        if ($pattern === '') {
251
            throw new ClientException(
252
                'Pattern cannot be empty',
253
                SDK::INVALID_ARGUMENT
254
            );
255
        }
256
257
        return $pattern;
258
    }
259
}
260