@@ 693-702 (lines=10) @@ | ||
690 | * |
|
691 | * @throws InvalidArgumentException |
|
692 | */ |
|
693 | public static function ip($value, $message = '') |
|
694 | { |
|
695 | static::string($value, $message); |
|
696 | if (false === \filter_var($value, \FILTER_VALIDATE_IP)) { |
|
697 | static::reportInvalidArgument(\sprintf( |
|
698 | $message ?: 'Expected a value to be an IP. Got: %s', |
|
699 | static::valueToString($value) |
|
700 | )); |
|
701 | } |
|
702 | } |
|
703 | ||
704 | /** |
|
705 | * @psalm-assert string $value |
|
@@ 712-721 (lines=10) @@ | ||
709 | * |
|
710 | * @throws InvalidArgumentException |
|
711 | */ |
|
712 | public static function ipv4($value, $message = '') |
|
713 | { |
|
714 | static::string($value, $message); |
|
715 | if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) { |
|
716 | static::reportInvalidArgument(\sprintf( |
|
717 | $message ?: 'Expected a value to be an IPv4. Got: %s', |
|
718 | static::valueToString($value) |
|
719 | )); |
|
720 | } |
|
721 | } |
|
722 | ||
723 | /** |
|
724 | * @psalm-assert string $value |
|
@@ 731-740 (lines=10) @@ | ||
728 | * |
|
729 | * @throws InvalidArgumentException |
|
730 | */ |
|
731 | public static function ipv6($value, $message = '') |
|
732 | { |
|
733 | static::string($value, $message); |
|
734 | if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) { |
|
735 | static::reportInvalidArgument(\sprintf( |
|
736 | $message ?: 'Expected a value to be an IPv6. Got %s', |
|
737 | static::valueToString($value) |
|
738 | )); |
|
739 | } |
|
740 | } |
|
741 | ||
742 | /** |
|
743 | * @psalm-assert string $value |
|
@@ 750-759 (lines=10) @@ | ||
747 | * |
|
748 | * @throws InvalidArgumentException |
|
749 | */ |
|
750 | public static function email($value, $message = '') |
|
751 | { |
|
752 | static::string($value, $message); |
|
753 | if (false === \filter_var($value, FILTER_VALIDATE_EMAIL)) { |
|
754 | static::reportInvalidArgument(\sprintf( |
|
755 | $message ?: 'Expected a value to be a valid e-mail address. Got %s', |
|
756 | static::valueToString($value) |
|
757 | )); |
|
758 | } |
|
759 | } |
|
760 | ||
761 | /** |
|
762 | * Does non strict comparisons on the items, so ['3', 3] will not pass the assertion. |