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