| @@ 447-457 (lines=11) @@ | ||
| 444 | } |
|
| 445 | } |
|
| 446 | ||
| 447 | public static function range($value, $min, $max, $message = '') |
|
| 448 | { |
|
| 449 | if ($value < $min || $value > $max) { |
|
| 450 | static::reportProblem(sprintf( |
|
| 451 | $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 452 | static::valueToString($value), |
|
| 453 | static::valueToString($min), |
|
| 454 | static::valueToString($max) |
|
| 455 | )); |
|
| 456 | } |
|
| 457 | } |
|
| 458 | ||
| 459 | public static function oneOf($value, array $values, $message = '') |
|
| 460 | { |
|
| @@ 640-652 (lines=13) @@ | ||
| 637 | } |
|
| 638 | } |
|
| 639 | ||
| 640 | public static function lengthBetween($value, $min, $max, $message = '') |
|
| 641 | { |
|
| 642 | $length = static::strlen($value); |
|
| 643 | ||
| 644 | if ($length < $min || $length > $max) { |
|
| 645 | static::reportProblem(sprintf( |
|
| 646 | $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 647 | static::valueToString($value), |
|
| 648 | $min, |
|
| 649 | $max |
|
| 650 | )); |
|
| 651 | } |
|
| 652 | } |
|
| 653 | ||
| 654 | public static function fileExists($value, $message = '') |
|
| 655 | { |
|