| Total Complexity | 13 |
| Total Lines | 103 |
| Duplicated Lines | 0 % |
| Coverage | 81.82% |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | class TreeWalkerChainIterator implements Iterator, ArrayAccess |
||
| 15 | { |
||
| 16 | /** @var TreeWalker[] */ |
||
| 17 | private $walkers = []; |
||
| 18 | /** @var TreeWalkerChain */ |
||
| 19 | private $treeWalkerChain; |
||
| 20 | /** @var Query */ |
||
| 21 | private $query; |
||
| 22 | /** @var ParserResult */ |
||
| 23 | private $parserResult; |
||
| 24 | |||
| 25 | 98 | public function __construct(TreeWalkerChain $treeWalkerChain, $query, $parserResult) |
|
| 26 | { |
||
| 27 | 98 | $this->treeWalkerChain = $treeWalkerChain; |
|
| 28 | 98 | $this->query = $query; |
|
| 29 | 98 | $this->parserResult = $parserResult; |
|
| 30 | 98 | } |
|
| 31 | |||
| 32 | /** |
||
| 33 | * {@inheritdoc} |
||
| 34 | */ |
||
| 35 | 98 | public function rewind() |
|
| 36 | { |
||
| 37 | 98 | return reset($this->walkers); |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * {@inheritdoc} |
||
| 42 | */ |
||
| 43 | 98 | public function current() |
|
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * {@inheritdoc} |
||
| 50 | */ |
||
| 51 | public function key() |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * {@inheritdoc} |
||
| 58 | */ |
||
| 59 | 92 | public function next() |
|
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * {@inheritdoc} |
||
| 68 | */ |
||
| 69 | 98 | public function valid() |
|
| 70 | { |
||
| 71 | 98 | return key($this->walkers) !== null; |
|
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * {@inheritdoc} |
||
| 76 | */ |
||
| 77 | 98 | public function offsetExists($offset) |
|
| 78 | { |
||
| 79 | 98 | return isset($this->walkers[$offset]); |
|
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * {@inheritdoc} |
||
| 84 | */ |
||
| 85 | 98 | public function offsetGet($offset) |
|
| 86 | { |
||
| 87 | 98 | if ($this->offsetExists($offset)) { |
|
| 88 | 98 | return new $this->walkers[$offset]( |
|
| 89 | 98 | $this->query, |
|
| 90 | 98 | $this->parserResult, |
|
| 91 | 98 | $this->treeWalkerChain->getQueryComponents() |
|
| 92 | ); |
||
| 93 | } |
||
| 94 | |||
| 95 | 92 | return null; |
|
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * {@inheritdoc} |
||
| 100 | */ |
||
| 101 | 98 | public function offsetSet($offset, $value) |
|
| 102 | { |
||
| 103 | 98 | if ($offset === null) { |
|
| 104 | 98 | $this->walkers[] = $value; |
|
| 105 | } else { |
||
| 106 | $this->walkers[$offset] = $value; |
||
| 107 | } |
||
| 108 | 98 | } |
|
| 109 | |||
| 110 | /** |
||
| 111 | * {@inheritdoc} |
||
| 112 | */ |
||
| 113 | public function offsetUnset($offset) |
||
| 117 | } |
||
| 118 | } |
||
| 119 | } |
||
| 120 |