Total Complexity | 6 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
10 | class ProviderArray implements ProviderInterface |
||
11 | { |
||
12 | /** @var array<int, array<scalar|null>> */ |
||
13 | private array $dataset; |
||
14 | |||
15 | private int $index; |
||
16 | |||
17 | private int $count; |
||
18 | |||
19 | /** @param array<array<scalar|null>> $dataset */ |
||
20 | 3 | public function __construct(array $dataset) |
|
21 | { |
||
22 | 3 | $this->dataset = array_values($dataset); |
|
23 | 3 | $this->count = count($this->dataset); |
|
24 | 3 | $this->index = 0; |
|
25 | } |
||
26 | |||
27 | 3 | public function get(string $key) |
|
28 | { |
||
29 | 3 | if (! $this->valid()) { |
|
30 | 2 | return null; |
|
31 | } |
||
32 | 3 | return ProviderGetValue::get($this->dataset[$this->index], $key); |
|
33 | } |
||
34 | |||
35 | 3 | public function next(): void |
|
36 | { |
||
37 | 3 | $this->index = $this->index + 1; |
|
38 | } |
||
39 | |||
40 | 3 | public function valid(): bool |
|
41 | { |
||
42 | 3 | return ($this->index < $this->count); |
|
43 | } |
||
44 | |||
45 | 1 | public function count(): int |
|
48 | } |
||
49 | } |
||
50 |