1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlibabaCloud\Client\Filter; |
4
|
|
|
|
5
|
|
|
use AlibabaCloud\Client\Exception\ClientException; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class ApiFilter |
9
|
|
|
* |
10
|
|
|
* @package AlibabaCloud\Client\Filter |
11
|
|
|
*/ |
12
|
|
|
class ApiFilter |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @param $serviceCode |
16
|
|
|
* |
17
|
|
|
* @return mixed |
18
|
|
|
* @throws ClientException |
19
|
|
|
*/ |
20
|
9 |
|
public static function serviceCode($serviceCode) |
21
|
|
|
{ |
22
|
9 |
|
if (!is_string($serviceCode)) { |
23
|
1 |
|
throw new ClientException( |
24
|
1 |
|
'Service Code must be a string', |
25
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
26
|
1 |
|
); |
27
|
|
|
} |
28
|
|
|
|
29
|
8 |
|
if ($serviceCode === '') { |
30
|
1 |
|
throw new ClientException( |
31
|
1 |
|
'Service Code cannot be empty', |
32
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
33
|
1 |
|
); |
34
|
|
|
} |
35
|
|
|
|
36
|
7 |
|
return $serviceCode; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param $endpointType |
41
|
|
|
* |
42
|
|
|
* @return mixed |
43
|
|
|
* @throws ClientException |
44
|
|
|
*/ |
45
|
8 |
|
public static function endpointType($endpointType) |
46
|
|
|
{ |
47
|
8 |
|
if (!is_string($endpointType)) { |
48
|
1 |
|
throw new ClientException( |
49
|
1 |
|
'Endpoint Type must be a string', |
50
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
51
|
1 |
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
7 |
|
if ($endpointType === '') { |
55
|
1 |
|
throw new ClientException( |
56
|
1 |
|
'Endpoint Type cannot be empty', |
57
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
58
|
1 |
|
); |
59
|
|
|
} |
60
|
|
|
|
61
|
6 |
|
return $endpointType; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param $action |
66
|
|
|
* |
67
|
|
|
* @return mixed |
68
|
|
|
* @throws ClientException |
69
|
|
|
*/ |
70
|
85 |
|
public static function action($action) |
71
|
|
|
{ |
72
|
85 |
|
if (!is_string($action)) { |
73
|
1 |
|
throw new ClientException( |
74
|
1 |
|
'Action must be a string', |
75
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
76
|
1 |
|
); |
77
|
|
|
} |
78
|
|
|
|
79
|
84 |
|
if ($action === '') { |
80
|
1 |
|
throw new ClientException( |
81
|
1 |
|
'Action cannot be empty', |
82
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
83
|
1 |
|
); |
84
|
|
|
} |
85
|
|
|
|
86
|
83 |
|
return $action; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param $version |
91
|
|
|
* |
92
|
|
|
* @return mixed |
93
|
|
|
* @throws ClientException |
94
|
|
|
*/ |
95
|
88 |
|
public static function version($version) |
96
|
|
|
{ |
97
|
88 |
|
if (!is_string($version)) { |
98
|
1 |
|
throw new ClientException( |
99
|
1 |
|
'Version must be a string', |
100
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
101
|
1 |
|
); |
102
|
|
|
} |
103
|
|
|
|
104
|
87 |
|
if ($version === '') { |
105
|
1 |
|
throw new ClientException( |
106
|
1 |
|
'Version cannot be empty', |
107
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
108
|
1 |
|
); |
109
|
|
|
} |
110
|
|
|
|
111
|
86 |
|
return $version; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param $format |
116
|
|
|
* |
117
|
|
|
* @return mixed |
118
|
|
|
* @throws ClientException |
119
|
|
|
*/ |
120
|
16 |
|
public static function format($format) |
121
|
|
|
{ |
122
|
16 |
|
if (!is_string($format)) { |
123
|
2 |
|
throw new ClientException( |
124
|
2 |
|
'Format must be a string', |
125
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
126
|
2 |
|
); |
127
|
|
|
} |
128
|
|
|
|
129
|
14 |
|
if ($format === '') { |
130
|
2 |
|
throw new ClientException( |
131
|
2 |
|
'Format cannot be empty', |
132
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
133
|
2 |
|
); |
134
|
|
|
} |
135
|
|
|
|
136
|
12 |
|
return $format; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param $product |
141
|
|
|
* |
142
|
|
|
* @return string |
143
|
|
|
* |
144
|
|
|
* @throws ClientException |
145
|
|
|
*/ |
146
|
114 |
|
public static function product($product) |
147
|
|
|
{ |
148
|
114 |
|
if (!is_string($product)) { |
149
|
6 |
|
throw new ClientException( |
150
|
6 |
|
'Product must be a string', |
151
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
152
|
6 |
|
); |
153
|
|
|
} |
154
|
|
|
|
155
|
108 |
|
if ($product === '') { |
156
|
3 |
|
throw new ClientException( |
157
|
3 |
|
'Product cannot be empty', |
158
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
159
|
3 |
|
); |
160
|
|
|
} |
161
|
|
|
|
162
|
105 |
|
return $product; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @param $pattern |
167
|
|
|
* |
168
|
|
|
* @return string |
169
|
|
|
* |
170
|
|
|
* @throws ClientException |
171
|
|
|
*/ |
172
|
10 |
|
public static function pattern($pattern) |
173
|
|
|
{ |
174
|
10 |
|
if (!is_string($pattern)) { |
175
|
1 |
|
throw new ClientException( |
176
|
1 |
|
'Pattern must be a string', |
177
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
178
|
1 |
|
); |
179
|
|
|
} |
180
|
|
|
|
181
|
9 |
|
if ($pattern === '') { |
182
|
1 |
|
throw new ClientException( |
183
|
1 |
|
'Pattern cannot be empty', |
184
|
|
|
\ALIBABA_CLOUD_INVALID_ARGUMENT |
185
|
1 |
|
); |
186
|
|
|
} |
187
|
|
|
|
188
|
8 |
|
return $pattern; |
189
|
|
|
} |
190
|
|
|
} |
191
|
|
|
|