Total Complexity | 7 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | final class Storage implements StorageInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var string[] |
||
13 | */ |
||
14 | private array $loadedPaths = []; |
||
15 | /** |
||
16 | * @var string[] |
||
17 | */ |
||
18 | private array $paths = []; |
||
19 | |||
20 | 44 | #[\Override] |
|
21 | public function getPath(): string|false |
||
22 | { |
||
23 | 44 | $key = key($this->paths); |
|
24 | 44 | if ($key === null) { |
|
25 | 42 | return false; |
|
26 | } |
||
27 | 44 | $result = $this->paths[$key]; |
|
28 | 44 | unset($this->paths[$key]); |
|
29 | 44 | return $result; |
|
30 | } |
||
31 | |||
32 | 44 | #[\Override] |
|
33 | public function isLoaded(string $path): bool |
||
34 | { |
||
35 | 44 | return in_array($path, $this->loadedPaths, true); |
|
36 | } |
||
37 | |||
38 | 42 | #[\Override] |
|
39 | public function markLoaded(string $path): void |
||
40 | { |
||
41 | 42 | $this->loadedPaths[] = $path; |
|
42 | } |
||
43 | |||
44 | 44 | #[\Override] |
|
45 | public function addPath(string $path): void |
||
46 | { |
||
47 | 44 | $path = realpath($path); |
|
48 | 44 | if ($path !== false) { |
|
49 | 44 | $this->paths[] = $path; |
|
50 | } |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @return string[] |
||
55 | */ |
||
56 | 2 | #[\Override] |
|
60 | } |
||
61 | } |
||
62 |