1 | <?php |
||
11 | class StrategyCollection implements \ArrayAccess |
||
12 | { |
||
13 | const STATUS_DISABLED = 0; |
||
14 | const STATUS_ENABLED = 1; |
||
15 | |||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | public $strategies; |
||
20 | |||
21 | protected $resolver; |
||
22 | |||
23 | protected $status = 1; |
||
24 | |||
25 | protected $threshold = 1; |
||
26 | |||
27 | |||
28 | /** |
||
29 | * @param array $strategies |
||
30 | */ |
||
31 | public function __construct($strategies = array()) |
||
36 | |||
37 | |||
38 | /** |
||
39 | * Adds strategies to feature object. |
||
40 | * |
||
41 | * @param string|array $name |
||
42 | * @param callable|StrategyInterface|null $strategy |
||
43 | * |
||
44 | * @return $this |
||
45 | */ |
||
46 | public function add($name, $strategy = null, $args = []) |
||
60 | |||
61 | |||
62 | /** |
||
63 | * Adds strategy to feature object. |
||
64 | * |
||
65 | * @param string $name |
||
66 | * @param callable|StrategyInterface|null $class Strategy class name. |
||
67 | * @param array $args |
||
68 | * |
||
69 | * @return $this |
||
70 | * @throws InvalidArgumentException |
||
71 | */ |
||
72 | public function addStrategy($name, $class = null, $args = []) |
||
104 | |||
105 | |||
106 | public function count() |
||
110 | |||
111 | |||
112 | public function flush() |
||
116 | |||
117 | |||
118 | /** |
||
119 | * @param array $args |
||
120 | * |
||
121 | * @return bool |
||
122 | */ |
||
123 | public function check($args = []) |
||
142 | |||
143 | |||
144 | protected function callStrategyInstance($strategy, $args = []) |
||
153 | |||
154 | |||
155 | /** |
||
156 | * (PHP 5 >= 5.0.0)<br/> |
||
157 | * Whether a offset exists. |
||
158 | * |
||
159 | * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
||
160 | * |
||
161 | * @param mixed $offset <p> |
||
162 | * An offset to check for. |
||
163 | * </p> |
||
164 | * |
||
165 | * @return bool true on success or false on failure. |
||
166 | * </p> |
||
167 | * <p> |
||
168 | * The return value will be casted to boolean if non-boolean was returned. |
||
169 | */ |
||
170 | public function offsetExists($offset) |
||
174 | |||
175 | |||
176 | /** |
||
177 | * (PHP 5 >= 5.0.0)<br/> |
||
178 | * Offset to retrieve. |
||
179 | * |
||
180 | * @link http://php.net/manual/en/arrayaccess.offsetget.php |
||
181 | * |
||
182 | * @param mixed $offset <p> |
||
183 | * The offset to retrieve. |
||
184 | * </p> |
||
185 | * |
||
186 | * @return mixed Can return all value types. |
||
187 | */ |
||
188 | public function offsetGet($offset) |
||
192 | |||
193 | |||
194 | /** |
||
195 | * (PHP 5 >= 5.0.0)<br/> |
||
196 | * Offset to set. |
||
197 | * |
||
198 | * @link http://php.net/manual/en/arrayaccess.offsetset.php |
||
199 | * |
||
200 | * @param mixed $offset <p> |
||
201 | * The offset to assign the value to. |
||
202 | * </p> |
||
203 | * @param mixed $value <p> |
||
204 | * The value to set. |
||
205 | * </p> |
||
206 | */ |
||
207 | public function offsetSet($offset, $value) |
||
211 | |||
212 | |||
213 | /** |
||
214 | * (PHP 5 >= 5.0.0)<br/> |
||
215 | * Offset to unset. |
||
216 | * |
||
217 | * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
||
218 | * |
||
219 | * @param mixed $offset <p> |
||
220 | * The offset to unset. |
||
221 | * </p> |
||
222 | */ |
||
223 | public function offsetUnset($offset) |
||
227 | |||
228 | |||
229 | public function off() |
||
235 | |||
236 | |||
237 | public function on() |
||
243 | |||
244 | |||
245 | public function getStatus() |
||
249 | |||
250 | |||
251 | /** |
||
252 | * @param int $threshold |
||
253 | * |
||
254 | * @return StrategyCollection |
||
255 | */ |
||
256 | public function setThreshold($threshold) |
||
262 | |||
263 | |||
264 | protected function isAnonymousFunctionStrategy($strategy = []) |
||
268 | |||
269 | |||
270 | /** |
||
271 | * @return int |
||
272 | */ |
||
273 | public function getThreshold() |
||
277 | |||
278 | |||
279 | /** |
||
280 | * @return array |
||
281 | */ |
||
282 | public function getStrategies() |
||
286 | } |
||
287 |