Code Duplication    Length = 10-10 lines in 4 locations

src/Assert.php 4 locations

@@ 704-713 (lines=10) @@
701
     *
702
     * @throws InvalidArgumentException
703
     */
704
    public static function ip($value, $message = '')
705
    {
706
        static::string($value, $message);
707
        if (false === \filter_var($value, \FILTER_VALIDATE_IP)) {
708
            static::reportInvalidArgument(\sprintf(
709
                $message ?: 'Expected a value to be an IP. Got: %s',
710
                static::valueToString($value)
711
            ));
712
        }
713
    }
714
715
    /**
716
     * @psalm-assert string $value
@@ 723-732 (lines=10) @@
720
     *
721
     * @throws InvalidArgumentException
722
     */
723
    public static function ipv4($value, $message = '')
724
    {
725
        static::string($value, $message);
726
        if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
727
            static::reportInvalidArgument(\sprintf(
728
                $message ?: 'Expected a value to be an IPv4. Got: %s',
729
                static::valueToString($value)
730
            ));
731
        }
732
    }
733
734
    /**
735
     * @psalm-assert string $value
@@ 742-751 (lines=10) @@
739
     *
740
     * @throws InvalidArgumentException
741
     */
742
    public static function ipv6($value, $message = '')
743
    {
744
        static::string($value, $message);
745
        if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
746
            static::reportInvalidArgument(\sprintf(
747
                $message ?: 'Expected a value to be an IPv6. Got %s',
748
                static::valueToString($value)
749
            ));
750
        }
751
    }
752
753
    /**
754
     * @psalm-assert string $value
@@ 761-770 (lines=10) @@
758
     *
759
     * @throws InvalidArgumentException
760
     */
761
    public static function email($value, $message = '')
762
    {
763
        static::string($value, $message);
764
        if (false === \filter_var($value, FILTER_VALIDATE_EMAIL)) {
765
            static::reportInvalidArgument(\sprintf(
766
                $message ?: 'Expected a value to be a valid e-mail address. Got %s',
767
                static::valueToString($value)
768
            ));
769
        }
770
    }
771
772
    /**
773
     * Does non strict comparisons on the items, so ['3', 3] will not pass the assertion.