1 | <?php |
||
15 | class Configuration |
||
16 | { |
||
17 | /** |
||
18 | * Connection timeout |
||
19 | * |
||
20 | * @var double |
||
21 | */ |
||
22 | private $connectTimeout; |
||
23 | |||
24 | /** |
||
25 | * I/O operations timeout |
||
26 | * |
||
27 | * @var double |
||
28 | */ |
||
29 | private $ioTimeout; |
||
30 | |||
31 | /** |
||
32 | * Aliases of preferred RequestExecutor engines |
||
33 | * |
||
34 | * @var string[] |
||
35 | */ |
||
36 | private $preferredEngines = []; |
||
37 | |||
38 | /** |
||
39 | * Default stream context for sockets |
||
40 | * |
||
41 | * @var StreamContext |
||
42 | */ |
||
43 | private $streamContext; |
||
44 | |||
45 | /** |
||
46 | * Minimum receive speed |
||
47 | * |
||
48 | * @var int|null |
||
49 | */ |
||
50 | private $minReceiveSpeed; |
||
51 | |||
52 | /** |
||
53 | * Minimum receive speed duration |
||
54 | * |
||
55 | * @var int|null |
||
56 | */ |
||
57 | private $minReceiveSpeedDuration; |
||
58 | |||
59 | /** |
||
60 | * Minimum send speed |
||
61 | * |
||
62 | * @var int|null |
||
63 | */ |
||
64 | private $minSendSpeed; |
||
65 | |||
66 | /** |
||
67 | * Minimum send speed duration |
||
68 | * |
||
69 | * @var int|null |
||
70 | */ |
||
71 | private $minSendSpeedDuration; |
||
72 | |||
73 | /** |
||
74 | * Configuration constructor. |
||
75 | * |
||
76 | * @param array $options { |
||
77 | * Array with options |
||
78 | * |
||
79 | * @var double $connectTimeout Connection timeout, in seconds |
||
80 | * @var double $ioTimeout Timeout on I/O operations, in seconds |
||
81 | * @var string[] $preferredEngines Array with aliases of preferred RequestExecutor engines |
||
82 | * @var array|resource|null $streamContext Any valid stream context created by stream_context_create function |
||
83 | * or null or array with options. Will be passed to the socket open method. If array value is used, |
||
84 | * then it should contain two nested keys: "options" and "params", which will be passed to |
||
85 | * stream_context_create parameters respectively. |
||
86 | * @var int $minReceiveSpeed Minimum speed required for receiving transfer in bytes per second |
||
87 | * @var int $minReceiveSpeedDuration Duration of transfer speed is below than minimum after which request |
||
88 | * should be aborted, in seconds |
||
89 | * @var int $minSendSpeed Minimum speed required for sending transfer in bytes per second |
||
90 | * @var int $minSendSpeedDuration Duration of transfer speed is below than minimum after which request |
||
91 | * should be aborted, in seconds |
||
92 | * } |
||
93 | */ |
||
94 | 179 | public function __construct(array $options = []) |
|
107 | |||
108 | /** |
||
109 | * Return ConnectTimeout |
||
110 | * |
||
111 | * @return float |
||
112 | */ |
||
113 | 162 | public function getConnectTimeout() |
|
117 | |||
118 | /** |
||
119 | * Return IoTimeout |
||
120 | * |
||
121 | * @return float |
||
122 | */ |
||
123 | 162 | public function getIoTimeout() |
|
127 | |||
128 | /** |
||
129 | * Return PreferredEngines |
||
130 | * |
||
131 | * @return string[] |
||
132 | */ |
||
133 | 5 | public function getPreferredEngines() |
|
137 | |||
138 | /** |
||
139 | * Return default socket stream context |
||
140 | * |
||
141 | * @return resource |
||
142 | */ |
||
143 | 160 | public function getStreamContext() |
|
147 | |||
148 | /** |
||
149 | * Return MinReceiveSpeed |
||
150 | * |
||
151 | * @return int|null |
||
152 | */ |
||
153 | 162 | public function getMinReceiveSpeed() |
|
157 | |||
158 | /** |
||
159 | * Return MinReceiveSpeedDuration |
||
160 | * |
||
161 | * @return int|null |
||
162 | */ |
||
163 | 162 | public function getMinReceiveSpeedDuration() |
|
167 | |||
168 | /** |
||
169 | * Return MinSendSpeed |
||
170 | * |
||
171 | * @return int|null |
||
172 | */ |
||
173 | 162 | public function getMinSendSpeed() |
|
177 | |||
178 | /** |
||
179 | * Return MinSendSpeedDuration |
||
180 | * |
||
181 | * @return int|null |
||
182 | */ |
||
183 | 162 | public function getMinSendSpeedDuration() |
|
187 | |||
188 | /** |
||
189 | * Key-value array with default values for options |
||
190 | * |
||
191 | * @return array |
||
192 | */ |
||
193 | 179 | private function getDefaultOptions() |
|
209 | } |
||
210 |