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 | /** @var callable */ |
| 12 | protected $callable; |
| 13 | |
| 14 | /** |
| 15 | * @param Iterator $iterator |
| 16 | * @param callable $callable |
| 17 | */ |
| 18 | public function __construct( Iterator $iterator, $callable ) { |
| 19 | parent::__construct( $iterator ); |
| 20 | $this->callable = $callable; |
| 21 | } |
| 22 | |
| 23 | /** @return mixed */ |
| 24 | public function current() { |
| 25 | return ( $this->callable )( $this->iterator->current() ); |
| 26 | } |
| 27 | } |