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)) { |
|
|
|
|
138
|
|
|
throw new ClientException( |
139
|
|
|
'Milliseconds must be int', |
140
|
|
|
SDK::INVALID_ARGUMENT |
141
|
|
|
); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
return $Milliseconds; |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|