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