| Total Complexity | 7 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 75% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | final class GacelaJsonConfigItem |
||
| 8 | { |
||
| 9 | public const DEFAULT_TYPE = 'php'; |
||
| 10 | |||
| 11 | private const DEFAULT_PATH = 'config/*.php'; |
||
| 12 | private const DEFAULT_PATH_LOCAL = 'config/local.php'; |
||
| 13 | |||
| 14 | private string $type; |
||
| 15 | private string $path; |
||
| 16 | private string $pathLocal; |
||
| 17 | |||
| 18 | 5 | public static function fromArray(array $json): self |
|
| 19 | { |
||
| 20 | 5 | return new self( |
|
| 21 | 5 | (string)($json['type'] ?? self::DEFAULT_TYPE), |
|
| 22 | 5 | (string)($json['path'] ?? self::DEFAULT_PATH), |
|
| 23 | 5 | (string)($json['path_local'] ?? self::DEFAULT_PATH_LOCAL) |
|
| 24 | ); |
||
| 25 | } |
||
| 26 | |||
| 27 | 7 | public static function withDefaults(): self |
|
| 30 | } |
||
| 31 | |||
| 32 | 12 | private function __construct( |
|
| 33 | string $type = self::DEFAULT_TYPE, |
||
| 34 | string $path = self::DEFAULT_PATH, |
||
| 35 | string $pathLocal = self::DEFAULT_PATH_LOCAL |
||
| 36 | ) { |
||
| 37 | 12 | $this->type = $type; |
|
| 38 | 12 | $this->path = $path; |
|
| 39 | 12 | $this->pathLocal = $pathLocal; |
|
| 40 | 12 | } |
|
| 41 | |||
| 42 | 12 | public function type(): string |
|
| 43 | { |
||
| 44 | 12 | return $this->type; |
|
| 45 | } |
||
| 46 | |||
| 47 | 12 | public function path(): string |
|
| 48 | { |
||
| 49 | 12 | return $this->path; |
|
| 50 | } |
||
| 51 | |||
| 52 | 12 | public function pathLocal(): string |
|
| 55 | } |
||
| 56 | |||
| 57 | public function __toString(): string |
||
| 64 | ); |
||
| 65 | } |
||
| 66 | } |
||
| 67 |