| Total Complexity | 7 |
| Total Lines | 46 |
| 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 | 43 | public function getPath(): string|false |
|
| 21 | { |
||
| 22 | 43 | $key = key($this->paths); |
|
| 23 | 43 | if ($key === null) { |
|
| 24 | 41 | return false; |
|
| 25 | } |
||
| 26 | 43 | $result = $this->paths[$key]; |
|
| 27 | 43 | unset($this->paths[$key]); |
|
| 28 | 43 | return $result; |
|
| 29 | } |
||
| 30 | |||
| 31 | 43 | public function isLoaded(string $path): bool |
|
| 32 | { |
||
| 33 | 43 | return in_array($path, $this->loadedPaths, true); |
|
| 34 | } |
||
| 35 | |||
| 36 | 41 | public function markLoaded(string $path): void |
|
| 37 | { |
||
| 38 | 41 | $this->loadedPaths[] = $path; |
|
| 39 | } |
||
| 40 | |||
| 41 | 43 | public function addPath(string $path): void |
|
| 42 | { |
||
| 43 | 43 | $path = realpath($path); |
|
| 44 | 43 | if ($path) { |
|
| 45 | 43 | $this->paths[] = $path; |
|
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @return string[] |
||
| 51 | */ |
||
| 52 | 2 | public function getLoadedPaths(): array |
|
| 55 | } |
||
| 56 | } |
||
| 57 |