Total Complexity | 7 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 93.75% |
Changes | 0 |
1 | <?php |
||
8 | class Records implements \IteratorAggregate, \Countable |
||
9 | { |
||
10 | /** |
||
11 | * @var array |
||
12 | */ |
||
13 | private $raw; |
||
14 | |||
15 | 2 | public function __construct(array $raw) |
|
16 | { |
||
17 | 2 | $this->raw = $raw; |
|
18 | 2 | } |
|
19 | |||
20 | 2 | public function getIterator(): \Traversable |
|
21 | { |
||
22 | 2 | return new \ArrayIterator($this->raw['records']); |
|
23 | } |
||
24 | |||
25 | 2 | public function count(): int |
|
26 | { |
||
27 | 2 | return count($this->raw['records']); |
|
28 | } |
||
29 | |||
30 | 2 | public function hasNext(): bool |
|
31 | { |
||
32 | 2 | return isset($this->raw['nextRecordsUrl']); |
|
33 | } |
||
34 | |||
35 | 2 | public function getNextIdentifier(): string |
|
36 | { |
||
37 | 2 | if (!$this->hasNext()) { |
|
38 | throw new \LogicException('Result has no next page'); |
||
39 | } |
||
40 | |||
41 | 2 | $uriParts = explode('/', $this->raw['nextRecordsUrl']); |
|
42 | |||
43 | 2 | return end($uriParts); |
|
44 | } |
||
45 | |||
46 | 2 | public function getTotalSize(): int |
|
49 | } |
||
50 | } |
||
51 |