Total Complexity | 3 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | final class SelectIterator implements IteratorAggregate |
||
9 | { |
||
10 | /** |
||
11 | * @var Traversable |
||
12 | */ |
||
13 | private $collection; |
||
14 | |||
15 | /** |
||
16 | * @var callable |
||
17 | */ |
||
18 | private $selector; |
||
19 | |||
20 | /** |
||
21 | * Create a SelectIterator from another iterator. |
||
22 | * |
||
23 | * @param Traversable $collection The iterator to be filtered. |
||
24 | * @param callable $selector The callback which should return values from each item in the iterator. |
||
25 | */ |
||
26 | public function __construct(Traversable $collection, callable $selector) |
||
27 | { |
||
28 | $this->collection = $collection; |
||
29 | $this->selector = $selector; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Returns an external iterator. |
||
34 | * |
||
35 | * @return Traversable |
||
36 | */ |
||
37 | public function getIterator() : Traversable |
||
41 | } |
||
42 | } |
||
44 |