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)) { |
|
|
|
|
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
|
|
|
return $endpointSuffix; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @codeCoverageIgnore |
119
|
|
|
* |
120
|
|
|
* @param string $network |
121
|
|
|
* |
122
|
|
|
* @return mixed |
123
|
|
|
* @throws ClientException |
124
|
|
|
*/ |
125
|
|
|
public static function network($network) |
126
|
|
|
{ |
127
|
|
|
if (!is_string($network)) { |
|
|
|
|
128
|
|
|
throw new ClientException( |
129
|
|
|
'Network Suffix must be a string', |
130
|
|
|
SDK::INVALID_ARGUMENT |
131
|
|
|
); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
if ($network === '') { |
135
|
|
|
throw new ClientException( |
136
|
|
|
'Network Suffix cannot be empty', |
137
|
|
|
SDK::INVALID_ARGUMENT |
138
|
|
|
); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
return $network; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param string $version |
146
|
|
|
* |
147
|
|
|
* @return mixed |
148
|
|
|
* @throws ClientException |
149
|
|
|
*/ |
150
|
74 |
|
public static function version($version) |
151
|
|
|
{ |
152
|
74 |
|
if (!is_string($version)) { |
|
|
|
|
153
|
1 |
|
throw new ClientException( |
154
|
1 |
|
'Version must be a string', |
155
|
|
|
SDK::INVALID_ARGUMENT |
156
|
1 |
|
); |
157
|
|
|
} |
158
|
|
|
|
159
|
73 |
|
if ($version === '') { |
160
|
1 |
|
throw new ClientException( |
161
|
1 |
|
'Version cannot be empty', |
162
|
|
|
SDK::INVALID_ARGUMENT |
163
|
1 |
|
); |
164
|
|
|
} |
165
|
|
|
|
166
|
72 |
|
return $version; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @param $format |
171
|
|
|
* |
172
|
|
|
* @return mixed |
173
|
|
|
* @throws ClientException |
174
|
|
|
*/ |
175
|
14 |
|
public static function format($format) |
176
|
|
|
{ |
177
|
14 |
|
if (!is_string($format)) { |
178
|
1 |
|
throw new ClientException( |
179
|
1 |
|
'Format must be a string', |
180
|
|
|
SDK::INVALID_ARGUMENT |
181
|
1 |
|
); |
182
|
|
|
} |
183
|
|
|
|
184
|
13 |
|
if ($format === '') { |
185
|
1 |
|
throw new ClientException( |
186
|
1 |
|
'Format cannot be empty', |
187
|
|
|
SDK::INVALID_ARGUMENT |
188
|
1 |
|
); |
189
|
|
|
} |
190
|
|
|
|
191
|
12 |
|
return \strtoupper($format); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @param $product |
196
|
|
|
* |
197
|
|
|
* @return string |
198
|
|
|
* |
199
|
|
|
* @throws ClientException |
200
|
|
|
*/ |
201
|
104 |
|
public static function product($product) |
202
|
|
|
{ |
203
|
104 |
|
if (!is_string($product)) { |
204
|
6 |
|
throw new ClientException( |
205
|
6 |
|
'Product must be a string', |
206
|
|
|
SDK::INVALID_ARGUMENT |
207
|
6 |
|
); |
208
|
|
|
} |
209
|
|
|
|
210
|
98 |
|
if ($product === '') { |
211
|
3 |
|
throw new ClientException( |
212
|
3 |
|
'Product cannot be empty', |
213
|
|
|
SDK::INVALID_ARGUMENT |
214
|
3 |
|
); |
215
|
|
|
} |
216
|
|
|
|
217
|
95 |
|
return $product; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @param $pattern |
222
|
|
|
* |
223
|
|
|
* @return string |
224
|
|
|
* |
225
|
|
|
* @throws ClientException |
226
|
|
|
*/ |
227
|
10 |
|
public static function pattern($pattern) |
228
|
|
|
{ |
229
|
10 |
|
if (!is_string($pattern)) { |
230
|
1 |
|
throw new ClientException( |
231
|
1 |
|
'Pattern must be a string', |
232
|
|
|
SDK::INVALID_ARGUMENT |
233
|
1 |
|
); |
234
|
|
|
} |
235
|
|
|
|
236
|
9 |
|
if ($pattern === '') { |
237
|
1 |
|
throw new ClientException( |
238
|
1 |
|
'Pattern cannot be empty', |
239
|
|
|
SDK::INVALID_ARGUMENT |
240
|
1 |
|
); |
241
|
|
|
} |
242
|
|
|
|
243
|
8 |
|
return $pattern; |
244
|
|
|
} |
245
|
|
|
} |
246
|
|
|
|