1 | <?php |
||
5 | class LoopFactory |
||
6 | { |
||
7 | /** |
||
8 | * The stack of Loop instances |
||
9 | * |
||
10 | * @var Loop[] $stack |
||
11 | */ |
||
12 | protected $stack = []; |
||
13 | |||
14 | /** |
||
15 | * Creates a new loop with the given array and adds it to the stack |
||
16 | * |
||
17 | * @param array $items The array that will be iterated |
||
18 | * @return Loop |
||
19 | */ |
||
20 | 30 | public function newLoop($items) |
|
33 | |||
34 | /** |
||
35 | * Should be called after the loop has finished |
||
36 | * |
||
37 | * @param $loop |
||
38 | */ |
||
39 | 30 | public function endLoop(&$loop) |
|
51 | |||
52 | /** |
||
53 | * To be called first inside the foreach loop. Returns the current loop |
||
54 | * |
||
55 | * @return Loop $current The current loop data |
||
56 | */ |
||
57 | 30 | public function loop() |
|
64 | } |
||
65 |