| Total Complexity | 7 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | class ResourceRecordIterator extends \ArrayIterator |
||
| 17 | { |
||
| 18 | 27 | public function __construct(string $resourceRecord) |
|
| 19 | { |
||
| 20 | 27 | parent::__construct(explode(Tokens::SPACE, $resourceRecord)); |
|
| 21 | 27 | } |
|
| 22 | |||
| 23 | /** |
||
| 24 | * Return pointer to previous position. |
||
| 25 | */ |
||
| 26 | 25 | public function prev(): void |
|
| 27 | { |
||
| 28 | 25 | if (!$this->valid()) { |
|
| 29 | 1 | $this->end(); |
|
| 30 | |||
| 31 | 1 | return; |
|
| 32 | } |
||
| 33 | |||
| 34 | 25 | $this->seek((int) $this->key() - 1); |
|
| 35 | 25 | } |
|
| 36 | |||
| 37 | /** |
||
| 38 | * Set pointer to the end of the array. |
||
| 39 | */ |
||
| 40 | 1 | public function end(): void |
|
| 41 | { |
||
| 42 | 1 | $lastPos = $this->count() - 1; |
|
| 43 | 1 | $this->seek($lastPos); |
|
| 44 | 1 | } |
|
| 45 | |||
| 46 | /** |
||
| 47 | * Get all the remaining values of an iterator as an array. This will move the pointer to the end of the array. |
||
| 48 | * |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | 23 | public function getRemainingAsString(): string |
|
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | 3 | public function __toString(): string |
|
| 68 | } |
||
| 69 | } |
||
| 70 |