| Total Complexity | 9 |
| Total Lines | 79 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 6 | final class Identifier implements \Iterator, \Countable |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * @var array |
||
| 10 | */ |
||
| 11 | private $items; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var Identifier |
||
| 15 | */ |
||
| 16 | private $reverseItems = null; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Identifier constructor. |
||
| 20 | * |
||
| 21 | * @param string $identifier |
||
| 22 | */ |
||
| 23 | public function __construct(string $identifier) |
||
| 24 | { |
||
| 25 | $this->items = explode('.', $identifier); |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @return string |
||
| 30 | */ |
||
| 31 | public function current(): string |
||
| 32 | { |
||
| 33 | return current($this->items); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @return void |
||
| 38 | */ |
||
| 39 | public function next(): void |
||
| 40 | { |
||
| 41 | next($this->items); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @return int |
||
| 46 | */ |
||
| 47 | public function key(): int |
||
| 48 | { |
||
| 49 | return key($this->items); |
||
|
|
|||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return bool |
||
| 54 | */ |
||
| 55 | public function valid(): bool |
||
| 56 | { |
||
| 57 | return key($this->items) !== null; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return void |
||
| 62 | */ |
||
| 63 | public function rewind(): void |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return int |
||
| 70 | */ |
||
| 71 | public function count(): int |
||
| 72 | { |
||
| 73 | return count($this->items); |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @return Identifier |
||
| 78 | */ |
||
| 79 | public function reverseItems(): Identifier |
||
| 85 | } |
||
| 86 | } |
||
| 87 |