| Total Complexity | 9 |
| Total Lines | 72 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class Circular implements \Iterator |
||
| 16 | { |
||
| 17 | /** @var array */ |
||
| 18 | protected $data; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Circular constructor. |
||
| 22 | * @param array $data |
||
| 23 | */ |
||
| 24 | public function __construct(array $data) |
||
| 25 | { |
||
| 26 | $this->data = $data; |
||
| 27 | reset($this->data); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function __invoke() |
||
| 31 | { |
||
| 32 | return $this->getElement(); |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @return mixed |
||
| 37 | */ |
||
| 38 | public function getElement() |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * {@inheritdoc} |
||
| 50 | */ |
||
| 51 | public function current() |
||
| 52 | { |
||
| 53 | return current($this->data); |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * {@inheritdoc} |
||
| 58 | */ |
||
| 59 | public function next(): void |
||
| 60 | { |
||
| 61 | next($this->data); |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * {@inheritdoc} |
||
| 66 | */ |
||
| 67 | public function key() |
||
| 68 | { |
||
| 69 | return key($this->data); |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * {@inheritdoc} |
||
| 74 | */ |
||
| 75 | public function valid(): bool |
||
| 76 | { |
||
| 77 | return |
||
| 78 | false !== current($this->data); |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * {@inheritdoc} |
||
| 83 | */ |
||
| 84 | public function rewind(): void |
||
| 87 | } |
||
| 88 | } |