| Total Complexity | 5 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | final class ServiceBuilder implements IServiceBuilder |
||
| 16 | { |
||
| 17 | private mixed $value; |
||
| 18 | private ?bool $isStorable = null; |
||
| 19 | private ?string $id = null; |
||
| 20 | |||
| 21 | public function build(): IService |
||
| 22 | { |
||
| 23 | $this->validate(); |
||
| 24 | |||
| 25 | return new Service( |
||
| 26 | value: $this->value, |
||
| 27 | storable: $this->isStorable, |
||
| 28 | id: $this->id, |
||
| 29 | ); |
||
| 30 | } |
||
| 31 | |||
| 32 | private function validate(): void |
||
| 33 | { |
||
| 34 | match (true) { |
||
| 35 | !isset($this->value) => throw new InvalidArgumentException('Value is not set.'), |
||
| 36 | $this->id === null => throw new InvalidArgumentException('Id is not set.'), |
||
| 37 | $this->isStorable === null => throw new InvalidArgumentException('isStorable is not set.'), |
||
| 38 | default => null, |
||
| 39 | }; |
||
| 40 | } |
||
| 41 | |||
| 42 | public function withValue(mixed $value): IServiceBuilder |
||
| 43 | { |
||
| 44 | $clone = clone $this; |
||
| 45 | $clone->value = $value; |
||
| 46 | return $clone; |
||
| 47 | } |
||
| 48 | |||
| 49 | public function withId(string $id): IServiceBuilder |
||
| 50 | { |
||
| 51 | $clone = clone $this; |
||
| 52 | $clone->id = $id; |
||
| 53 | return $clone; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function withIsStorable(bool $isStorable): IServiceBuilder |
||
| 61 | } |
||
| 62 | } |
||
| 63 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths