Conditions | 4 |
Paths | 5 |
Total Lines | 11 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
39 | 178 | public static function assertOneOf($value, array $values, string $message = ''): void |
|
40 | { |
||
41 | 178 | if (!in_array($value, $values, true)) { |
|
42 | 82 | $array = []; |
|
43 | 82 | foreach ($values as $key => $record) { |
|
44 | 82 | $array[$key] = self::valueToString($record); |
|
45 | } |
||
46 | 82 | $valuesString = implode(', ', $array); |
|
47 | 82 | $format = 0 === strlen($message) ? 'Expected one of %2$s. Got %1$s' : $message; |
|
48 | 82 | $message = sprintf($format, self::valueToString($value), $valuesString); |
|
49 | 82 | throw new InvalidArgumentException($message); |
|
50 | } |
||
53 |