| 1 | <?php |
||
| 27 | abstract class Transformation implements OuterIterator |
||
| 28 | { |
||
| 29 | use OuterIteratorTrait; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * The inner iterator being transformed |
||
| 33 | * |
||
| 34 | * @var IterableIterator |
||
| 35 | * @construct required |
||
| 36 | */ |
||
| 37 | protected $iterator; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * The current key |
||
| 41 | * |
||
| 42 | * @var scalar |
||
| 43 | */ |
||
| 44 | protected $key; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * The current value |
||
| 48 | * |
||
| 49 | * @var mixed |
||
| 50 | */ |
||
| 51 | protected $current; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Constructs the Transformation with the iterable original data |
||
| 55 | */ |
||
| 56 | 1 | public function __construct(iterable $iterator) |
|
| 60 | |||
| 61 | /** |
||
| 62 | * {@inheritDoc} |
||
| 63 | */ |
||
| 64 | 1 | public function rewind() |
|
| 69 | |||
| 70 | /** |
||
| 71 | * {@inheritDoc} |
||
| 72 | */ |
||
| 73 | 1 | public function next() |
|
| 78 | |||
| 79 | /** |
||
| 80 | * {@inheritDoc} |
||
| 81 | */ |
||
| 82 | 1 | public function current() |
|
| 86 | |||
| 87 | /** |
||
| 88 | * {@inheritDoc} |
||
| 89 | */ |
||
| 90 | 1 | public function key() |
|
| 94 | |||
| 95 | /** |
||
| 96 | * Calls the child class' process() method if and only if this is |
||
| 97 | * valid() |
||
| 98 | */ |
||
| 99 | 1 | private function doProcess() |
|
| 106 | |||
| 107 | /** |
||
| 108 | * Called on whenever the pointer is moved (on rewind() or next() |
||
| 109 | * calls) to process the current position place |
||
| 110 | */ |
||
| 111 | abstract protected function process(); |
||
| 112 | } |
||
| 113 |