jasny /
container
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Jasny\Container\Loader; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Base class for loader using two iterators. |
||
| 9 | */ |
||
| 10 | abstract class AbstractLoader implements \OuterIterator |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var \Iterator |
||
| 14 | */ |
||
| 15 | protected $items; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var \ArrayIterator|null |
||
| 19 | */ |
||
| 20 | protected $entries; |
||
| 21 | |||
| 22 | |||
| 23 | /** |
||
| 24 | * Class constructor. |
||
| 25 | * |
||
| 26 | * @param \Iterator $items |
||
| 27 | */ |
||
| 28 | 16 | public function __construct(\Iterator $items) |
|
| 29 | { |
||
| 30 | 16 | $this->items = $items; |
|
| 31 | 16 | $this->prepareNext(); |
|
| 32 | 15 | } |
|
| 33 | |||
| 34 | /** |
||
| 35 | * Prepare new entries |
||
| 36 | * |
||
| 37 | * @return void |
||
| 38 | */ |
||
| 39 | abstract protected function prepareNext(): void; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Return the current element |
||
| 43 | * |
||
| 44 | * @return callable|null |
||
| 45 | */ |
||
| 46 | 11 | public function current(): ?callable |
|
| 47 | { |
||
| 48 | 11 | return isset($this->entries) ? $this->entries->current() : null; |
|
|
1 ignored issue
–
show
|
|||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Move forward to next element |
||
| 53 | * |
||
| 54 | * @return void |
||
| 55 | */ |
||
| 56 | 11 | public function next(): void |
|
| 57 | { |
||
| 58 | 11 | if (!isset($this->entries)) { |
|
| 59 | // Shouldn't happen if `prepareNext()` works correctly |
||
| 60 | return; // @codeCoverageIgnore |
||
| 61 | } |
||
| 62 | |||
| 63 | 11 | $this->entries->next(); |
|
| 64 | |||
| 65 | 11 | while (!$this->entries->valid() && $this->items->valid()) { |
|
| 66 | 11 | $this->prepareNext(); |
|
| 67 | } |
||
| 68 | 10 | } |
|
| 69 | |||
| 70 | /** |
||
| 71 | * Return the key of the current element |
||
| 72 | * |
||
| 73 | * @return string|null |
||
| 74 | */ |
||
| 75 | 11 | public function key(): ?string |
|
| 76 | { |
||
| 77 | 11 | return isset($this->entries) ? $this->entries->key() : null; |
|
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Checks if current position is valid |
||
| 82 | * |
||
| 83 | * @return bool |
||
| 84 | */ |
||
| 85 | 13 | public function valid(): bool |
|
| 86 | { |
||
| 87 | 13 | return isset($this->entries) && $this->entries->valid(); |
|
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * Rewind the iterator to the first element |
||
| 92 | * |
||
| 93 | * @return void |
||
| 94 | */ |
||
| 95 | 13 | public function rewind(): void |
|
| 96 | { |
||
| 97 | 13 | $this->items->rewind(); |
|
| 98 | 13 | $this->entries = null; |
|
| 99 | |||
| 100 | 13 | $this->prepareNext(); |
|
| 101 | 13 | } |
|
| 102 | |||
| 103 | /** |
||
| 104 | * Returns the inner iterator for the current entry. |
||
| 105 | * |
||
| 106 | * @return \Iterator |
||
| 107 | */ |
||
| 108 | 2 | public function getInnerIterator(): \Iterator |
|
| 109 | { |
||
| 110 | 2 | return $this->items; |
|
| 111 | } |
||
| 112 | } |
||
| 113 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.