| 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 |
||
| 29 | 178 | public static function assertOneOf(mixed $value, array $values, string $message = ''): void |
|
| 30 | { |
||
| 31 | 178 | if (!in_array($value, $values, true)) { |
|
| 32 | 82 | $array = []; |
|
| 33 | 82 | foreach ($values as $key => $record) { |
|
| 34 | 82 | $array[$key] = self::valueToString($record); |
|
| 35 | } |
||
| 36 | 82 | $valuesString = implode(', ', $array); |
|
| 37 | 82 | $format = '' === $message ? 'Expected one of %2$s. Got %1$s' : $message; |
|
| 38 | 82 | $message = sprintf($format, self::valueToString($value), $valuesString); |
|
| 39 | 82 | throw new InvalidArgumentException($message); |
|
| 40 | } |
||
| 43 |