@@ 643-651 (lines=9) @@ | ||
640 | * @param mixed $value |
|
641 | * @param string $message |
|
642 | */ |
|
643 | public static function ip($value, $message = '') |
|
644 | { |
|
645 | if (false === \filter_var($value, \FILTER_VALIDATE_IP)) { |
|
646 | static::reportInvalidArgument(\sprintf( |
|
647 | $message ?: 'Expected a value to be an IP. Got: %s', |
|
648 | static::valueToString($value) |
|
649 | )); |
|
650 | } |
|
651 | } |
|
652 | ||
653 | /** |
|
654 | * @param mixed $value |
|
@@ 657-665 (lines=9) @@ | ||
654 | * @param mixed $value |
|
655 | * @param string $message |
|
656 | */ |
|
657 | public static function ipv4($value, $message = '') |
|
658 | { |
|
659 | if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) { |
|
660 | static::reportInvalidArgument(\sprintf( |
|
661 | $message ?: 'Expected a value to be an IPv4. Got: %s', |
|
662 | static::valueToString($value) |
|
663 | )); |
|
664 | } |
|
665 | } |
|
666 | ||
667 | /** |
|
668 | * @param mixed $value |
|
@@ 671-679 (lines=9) @@ | ||
668 | * @param mixed $value |
|
669 | * @param string $message |
|
670 | */ |
|
671 | public static function ipv6($value, $message = '') |
|
672 | { |
|
673 | if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) { |
|
674 | static::reportInvalidArgument(\sprintf( |
|
675 | $message ?: 'Expected a value to be an IPv6. Got %s', |
|
676 | static::valueToString($value) |
|
677 | )); |
|
678 | } |
|
679 | } |
|
680 | ||
681 | /** |
|
682 | * @param mixed $value |
|
@@ 685-693 (lines=9) @@ | ||
682 | * @param mixed $value |
|
683 | * @param string $message |
|
684 | */ |
|
685 | public static function email($value, $message = '') |
|
686 | { |
|
687 | if (false === \filter_var($value, FILTER_VALIDATE_EMAIL)) { |
|
688 | static::reportInvalidArgument(\sprintf( |
|
689 | $message ?: 'Expected a value to be a valid e-mail address. Got %s', |
|
690 | static::valueToString($value) |
|
691 | )); |
|
692 | } |
|
693 | } |
|
694 | ||
695 | /** |
|
696 | * Does non strict comparisons on the items, so ['3', 3] will not pass the assertion. |