Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
CallbackIterator | |
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
current | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace CirrusSearch\Iterator; |
4 | |
5 | use Iterator; |
6 | |
7 | /** |
8 | * Applies a callback to all values returned from the iterator |
9 | */ |
10 | class CallbackIterator extends IteratorDecorator { |
11 | protected $callable; |
12 | |
13 | public function __construct( Iterator $iterator, $callable ) { |
14 | parent::__construct( $iterator ); |
15 | $this->callable = $callable; |
16 | } |
17 | |
18 | public function current() { |
19 | return call_user_func( $this->callable, $this->iterator->current() ); |
20 | } |
21 | } |