Conditions | 4 |
Paths | 3 |
Total Lines | 11 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
40 | 70 | public static function assertRange(int $value, int $min, int $max, string $message = ''): void |
|
41 | { |
||
42 | 70 | if ($value < $min || $value > $max) { |
|
43 | 30 | $format = 0 === strlen($message) ? 'Expected a value between %2$s and %3$s. Got: %1$s' : $message; |
|
44 | 30 | $message = sprintf( |
|
45 | 30 | $format, |
|
46 | 30 | self::valueToString($value), |
|
47 | 30 | self::valueToString($min), |
|
48 | 30 | self::valueToString($max) |
|
49 | 30 | ); |
|
50 | 30 | throw new InvalidArgumentException($message); |
|
51 | } |
||
54 |