Total Complexity | 5 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class RequestsPool |
||
8 | { |
||
9 | /** |
||
10 | * @var Request[] |
||
11 | */ |
||
12 | private $requests = []; |
||
13 | |||
14 | /** |
||
15 | * @param Request $request |
||
16 | */ |
||
17 | public function add(Request $request) |
||
18 | { |
||
19 | $this->requests[] = $request; |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * @return Request |
||
24 | */ |
||
25 | public function shift() |
||
26 | { |
||
27 | return array_shift($this->requests); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param Exception $exception |
||
32 | */ |
||
33 | public function rejectAllWith(Exception $exception) |
||
34 | { |
||
35 | while (!$this->isEmpty()) { |
||
36 | $request = $this->shift(); |
||
37 | $request->reject($exception); |
||
38 | } |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @return bool |
||
43 | */ |
||
44 | public function isEmpty() |
||
47 | } |
||
48 | } |
||
49 |