@@ 322-330 (lines=9) @@ | ||
319 | } |
|
320 | } |
|
321 | ||
322 | public static function null($value, $message = '') |
|
323 | { |
|
324 | if (null !== $value) { |
|
325 | throw static::createInvalidArgumentException(sprintf( |
|
326 | $message ?: 'Expected null. Got: %s', |
|
327 | static::valueToString($value) |
|
328 | )); |
|
329 | } |
|
330 | } |
|
331 | ||
332 | public static function notNull($value, $message = '') |
|
333 | { |
|
@@ 341-349 (lines=9) @@ | ||
338 | } |
|
339 | } |
|
340 | ||
341 | public static function true($value, $message = '') |
|
342 | { |
|
343 | if (true !== $value) { |
|
344 | throw static::createInvalidArgumentException(sprintf( |
|
345 | $message ?: 'Expected a value to be true. Got: %s', |
|
346 | static::valueToString($value) |
|
347 | )); |
|
348 | } |
|
349 | } |
|
350 | ||
351 | public static function false($value, $message = '') |
|
352 | { |
|
@@ 351-359 (lines=9) @@ | ||
348 | } |
|
349 | } |
|
350 | ||
351 | public static function false($value, $message = '') |
|
352 | { |
|
353 | if (false !== $value) { |
|
354 | throw static::createInvalidArgumentException(sprintf( |
|
355 | $message ?: 'Expected a value to be false. Got: %s', |
|
356 | static::valueToString($value) |
|
357 | )); |
|
358 | } |
|
359 | } |
|
360 | ||
361 | public static function eq($value, $value2, $message = '') |
|
362 | { |
|
@@ 607-616 (lines=10) @@ | ||
604 | } |
|
605 | } |
|
606 | ||
607 | public static function length($value, $length, $message = '') |
|
608 | { |
|
609 | if ($length !== static::strlen($value)) { |
|
610 | throw static::createInvalidArgumentException(sprintf( |
|
611 | $message ?: 'Expected a value to contain %2$s characters. Got: %s', |
|
612 | static::valueToString($value), |
|
613 | $length |
|
614 | )); |
|
615 | } |
|
616 | } |
|
617 | ||
618 | public static function minLength($value, $min, $message = '') |
|
619 | { |
|
@@ 618-627 (lines=10) @@ | ||
615 | } |
|
616 | } |
|
617 | ||
618 | public static function minLength($value, $min, $message = '') |
|
619 | { |
|
620 | if (static::strlen($value) < $min) { |
|
621 | throw static::createInvalidArgumentException(sprintf( |
|
622 | $message ?: 'Expected a value to contain at least %2$s characters. Got: %s', |
|
623 | static::valueToString($value), |
|
624 | $min |
|
625 | )); |
|
626 | } |
|
627 | } |
|
628 | ||
629 | public static function maxLength($value, $max, $message = '') |
|
630 | { |
|
@@ 629-638 (lines=10) @@ | ||
626 | } |
|
627 | } |
|
628 | ||
629 | public static function maxLength($value, $max, $message = '') |
|
630 | { |
|
631 | if (static::strlen($value) > $max) { |
|
632 | throw static::createInvalidArgumentException(sprintf( |
|
633 | $message ?: 'Expected a value to contain at most %2$s characters. Got: %s', |
|
634 | static::valueToString($value), |
|
635 | $max |
|
636 | )); |
|
637 | } |
|
638 | } |
|
639 | ||
640 | public static function lengthBetween($value, $min, $max, $message = '') |
|
641 | { |