| Total Complexity | 10 |
| Total Lines | 120 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | final class GacelaConfigFile implements GacelaConfigFileInterface |
||
| 10 | { |
||
| 11 | /** @var list<GacelaConfigItem> */ |
||
| 12 | private array $configItems = []; |
||
| 13 | |||
| 14 | /** @var array<class-string,class-string|callable|object> */ |
||
|
1 ignored issue
–
show
|
|||
| 15 | private array $mappingInterfaces = []; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var array{ |
||
| 19 | * Factory:list<string>, |
||
| 20 | * Config:list<string>, |
||
| 21 | * DependencyProvider:list<string>, |
||
| 22 | * } |
||
| 23 | */ |
||
| 24 | private array $suffixTypes = SuffixTypesBuilder::DEFAULT_SUFFIX_TYPES; |
||
| 25 | |||
| 26 | 15 | public static function withDefaults(): self |
|
| 27 | { |
||
| 28 | 15 | return (new self()) |
|
| 29 | 15 | ->setConfigItems([new GacelaConfigItem()]); |
|
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param list<GacelaConfigItem> $configItems |
||
| 34 | */ |
||
| 35 | 47 | public function setConfigItems(array $configItems): self |
|
| 36 | { |
||
| 37 | 47 | $this->configItems = $configItems; |
|
| 38 | |||
| 39 | 47 | return $this; |
|
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @return list<GacelaConfigItem> |
||
| 44 | */ |
||
| 45 | 37 | public function getConfigItems(): array |
|
| 46 | { |
||
| 47 | 37 | return $this->configItems; |
|
|
1 ignored issue
–
show
|
|||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param array<class-string,class-string|callable|object> $mappingInterfaces |
||
|
1 ignored issue
–
show
|
|||
| 52 | */ |
||
| 53 | 41 | public function setMappingInterfaces(array $mappingInterfaces): self |
|
| 54 | { |
||
| 55 | 41 | $this->mappingInterfaces = $mappingInterfaces; |
|
| 56 | |||
| 57 | 41 | return $this; |
|
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Map interfaces to concrete classes or callable (which will be resolved on runtime). |
||
| 62 | * This is util to inject dependencies to Gacela services (such as Factories, for example) via their constructor. |
||
| 63 | * |
||
| 64 | * @return mixed |
||
| 65 | */ |
||
| 66 | 2 | public function getMappingInterface(string $key) |
|
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @return array<class-string,class-string|callable|object> |
||
|
1 ignored issue
–
show
|
|||
| 73 | */ |
||
| 74 | 15 | public function getMappingInterfaces(): array |
|
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @param array{ |
||
| 81 | * Factory:list<string>, |
||
| 82 | * Config:list<string>, |
||
| 83 | * DependencyProvider:list<string> |
||
| 84 | * } $suffixTypes |
||
| 85 | */ |
||
| 86 | 41 | public function setSuffixTypes(array $suffixTypes): self |
|
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @return array{ |
||
| 95 | * Factory:list<string>, |
||
| 96 | * Config:list<string>, |
||
| 97 | * DependencyProvider:list<string>, |
||
| 98 | * } |
||
| 99 | */ |
||
| 100 | 27 | public function getSuffixTypes(): array |
|
| 101 | { |
||
| 102 | 27 | return $this->suffixTypes; |
|
| 103 | } |
||
| 104 | |||
| 105 | 15 | public function combine(GacelaConfigFileInterface $other): GacelaConfigFileInterface |
|
| 116 | } |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @return list<string> |
||
| 120 | */ |
||
| 121 | 15 | private function filterList(GacelaConfigFileInterface $other, string $key): array |
|
| 129 | } |
||
| 130 | } |
||
| 131 |