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
|
101 |
|
public static function regionId($regionId) |
23
|
|
|
{ |
24
|
101 |
|
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
|
97 |
|
if ($regionId === '') { |
32
|
4 |
|
throw new ClientException( |
33
|
4 |
|
'Region ID cannot be empty', |
34
|
|
|
SDK::INVALID_ARGUMENT |
35
|
4 |
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
93 |
|
return $regionId; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param $clientName |
43
|
|
|
* |
44
|
|
|
* @return string |
45
|
|
|
* |
46
|
|
|
* @throws ClientException |
47
|
|
|
*/ |
48
|
161 |
|
public static function clientName($clientName) |
49
|
|
|
{ |
50
|
161 |
|
if (!is_string($clientName)) { |
51
|
5 |
|
throw new ClientException( |
52
|
5 |
|
'Client Name must be a string', |
53
|
|
|
SDK::INVALID_ARGUMENT |
54
|
5 |
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
156 |
|
if ($clientName === '') { |
58
|
5 |
|
throw new ClientException( |
59
|
5 |
|
'Client Name cannot be empty', |
60
|
|
|
SDK::INVALID_ARGUMENT |
61
|
5 |
|
); |
62
|
|
|
} |
63
|
|
|
|
64
|
151 |
|
return strtolower($clientName); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param $connectTimeout |
69
|
|
|
* |
70
|
|
|
* @return mixed |
71
|
|
|
* @throws ClientException |
72
|
|
|
*/ |
73
|
60 |
|
public static function connectTimeout($connectTimeout) |
74
|
|
|
{ |
75
|
60 |
|
if ($connectTimeout === '') { |
76
|
2 |
|
throw new ClientException( |
77
|
2 |
|
'Connect Timeout cannot be empty', |
78
|
|
|
SDK::INVALID_ARGUMENT |
79
|
2 |
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
58 |
|
return $connectTimeout; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param $timeout |
87
|
|
|
* |
88
|
|
|
* @return mixed |
89
|
|
|
* @throws ClientException |
90
|
|
|
*/ |
91
|
61 |
|
public static function timeout($timeout) |
92
|
|
|
{ |
93
|
61 |
|
if ($timeout === '') { |
94
|
2 |
|
throw new ClientException( |
95
|
2 |
|
'Timeout cannot be empty', |
96
|
|
|
SDK::INVALID_ARGUMENT |
97
|
2 |
|
); |
98
|
|
|
} |
99
|
|
|
|
100
|
59 |
|
return $timeout; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param int $Milliseconds |
105
|
|
|
* |
106
|
|
|
* @return mixed |
107
|
|
|
* @throws ClientException |
108
|
|
|
*/ |
109
|
4 |
|
public static function milliseconds($Milliseconds) |
110
|
|
|
{ |
111
|
4 |
|
if (!is_int($Milliseconds)) { |
|
|
|
|
112
|
2 |
|
throw new ClientException( |
113
|
2 |
|
'Milliseconds must be int', |
114
|
|
|
SDK::INVALID_ARGUMENT |
115
|
2 |
|
); |
116
|
|
|
} |
117
|
|
|
|
118
|
2 |
|
return $Milliseconds; |
119
|
|
|
} |
120
|
|
|
} |
121
|
|
|
|