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

Storage::markLoaded()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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