Passed
Push — feature/94-combine-gacela-file... ( 9cfe7e...ca95c3 )
by Chema
03:32
created

GacelaConfigItem   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 42
ccs 12
cts 14
cp 0.8571
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A reader() 0 3 1
A __construct() 0 8 1
A pathLocal() 0 3 1
A withDefaults() 0 3 1
A withPath() 0 3 1
A path() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\Config\GacelaFileConfig;
6
7
use Gacela\Framework\Config\ConfigReader\PhpConfigReader;
8
use Gacela\Framework\Config\ConfigReaderInterface;
9
10
final class GacelaConfigItem
11
{
12
    public const DEFAULT_PATH = 'config/*.php';
13
    public const DEFAULT_PATH_LOCAL = 'config/local.php';
14
15
    private string $path;
16
    private string $pathLocal;
17
    private ConfigReaderInterface $reader;
18
19 52
    public function __construct(
20
        string $path,
21
        string $pathLocal = self::DEFAULT_PATH_LOCAL,
22
        ?ConfigReaderInterface $reader = null
23
    ) {
24 52
        $this->path = $path;
25 52
        $this->pathLocal = $pathLocal;
26 52
        $this->reader = $reader ?? new PhpConfigReader();
27
    }
28
29 43
    public static function withDefaults(): self
30
    {
31 43
        return new self(self::DEFAULT_PATH);
32
    }
33
34
    public static function withPath(string $path): self
35
    {
36
        return new self($path);
37
    }
38
39 28
    public function path(): string
40
    {
41 28
        return $this->path;
42
    }
43
44 28
    public function pathLocal(): string
45
    {
46 28
        return $this->pathLocal;
47
    }
48
49 33
    public function reader(): ConfigReaderInterface
50
    {
51 33
        return $this->reader;
52
    }
53
}
54