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