Total Complexity | 6 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Coverage | 85.71% |
Changes | 0 |
1 | <?php |
||
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 |
|
52 | } |
||
53 | } |
||
54 |