Total Complexity | 4 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | class InvalidConfigurationException extends \UnexpectedValueException implements ConfigurationExceptionInterface |
||
20 | { |
||
21 | /** |
||
22 | * @param string $option Name/path of the option |
||
23 | * @param mixed $valueGiven The invalid option that was provided |
||
24 | * @param ?string $description Additional text describing the issue (optional) |
||
25 | */ |
||
26 | 9 | public static function forConfigOption(string $option, $valueGiven, ?string $description = null): self |
|
27 | { |
||
28 | 9 | $message = \sprintf('Invalid config option for "%s": %s', $option, self::getDebugValue($valueGiven)); |
|
29 | 9 | if ($description !== null) { |
|
30 | 3 | $message .= \sprintf(' (%s)', $description); |
|
31 | } |
||
32 | |||
33 | 9 | return new self($message); |
|
34 | } |
||
35 | |||
36 | /** |
||
37 | * @param mixed $value |
||
38 | */ |
||
39 | 9 | private static function getDebugValue($value): string |
|
46 | } |
||
47 | } |
||
48 |