Passed
Push — master ( 4b3d26...06dcf5 )
by Enjoys
12:36 queued 13s
created

Storage   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 46
ccs 17
cts 17
cp 1
rs 10
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getLoadedPaths() 0 3 1
A getPath() 0 9 2
A markLoaded() 0 3 1
A addPath() 0 5 2
A isLoaded() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
6
namespace Enjoys\Dotenv;
7
8
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
53
    {
54 2
        return $this->loadedPaths;
55
    }
56
}
57