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

GacelaConfigItem::withPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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