1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace AlecRabbit\Spinner\Core\Settings\Builder; |
6
|
|
|
|
7
|
|
|
use AlecRabbit\Spinner\Core\Settings\Contract\Builder\ISettingsProviderBuilder; |
8
|
|
|
use AlecRabbit\Spinner\Core\Settings\Contract\ISettings; |
9
|
|
|
use AlecRabbit\Spinner\Core\Settings\Contract\ISettingsProvider; |
10
|
|
|
use AlecRabbit\Spinner\Core\Settings\SettingsProvider; |
|
|
|
|
11
|
|
|
use AlecRabbit\Spinner\Exception\LogicException; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @psalm-suppress PossiblyNullArgument |
15
|
|
|
*/ |
16
|
|
|
final class SettingsProviderBuilder implements ISettingsProviderBuilder |
17
|
|
|
{ |
18
|
|
|
private ?ISettings $settings = null; |
19
|
|
|
private ?ISettings $defaultSettings = null; |
20
|
|
|
private ?ISettings $detectedSettings = null; |
21
|
|
|
|
22
|
|
|
public function build(): ISettingsProvider |
23
|
|
|
{ |
24
|
|
|
$this->validate(); |
25
|
|
|
|
26
|
|
|
return new SettingsProvider( |
27
|
|
|
userSettings: $this->settings, |
28
|
|
|
defaultSettings: $this->defaultSettings, |
29
|
|
|
detectedSettings: $this->detectedSettings, |
30
|
|
|
); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
private function validate(): void |
34
|
|
|
{ |
35
|
|
|
match (true) { |
36
|
|
|
$this->settings === null => throw new LogicException('User settings are not set.'), |
37
|
|
|
$this->defaultSettings === null => throw new LogicException('Default settings are not set.'), |
38
|
|
|
$this->detectedSettings === null => throw new LogicException('Detected settings are not set.'), |
39
|
|
|
default => null, |
40
|
|
|
}; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function withSettings(ISettings $settings): ISettingsProviderBuilder |
44
|
|
|
{ |
45
|
|
|
$clone = clone $this; |
46
|
|
|
$clone->settings = $settings; |
47
|
|
|
return $clone; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function withDefaultSettings(ISettings $settings): ISettingsProviderBuilder |
51
|
|
|
{ |
52
|
|
|
$clone = clone $this; |
53
|
|
|
$clone->defaultSettings = $settings; |
54
|
|
|
return $clone; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function withDetectedSettings(ISettings $settings): ISettingsProviderBuilder |
58
|
|
|
{ |
59
|
|
|
$clone = clone $this; |
60
|
|
|
$clone->detectedSettings = $settings; |
61
|
|
|
return $clone; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
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