Code Duplication    Length = 9-9 lines in 5 locations

src/Assert.php 5 locations

@@ 667-675 (lines=9) @@
664
     *
665
     * @throws InvalidArgumentException
666
     */
667
    public static function ip($value, $message = '')
668
    {
669
        if (false === \filter_var($value, \FILTER_VALIDATE_IP)) {
670
            static::reportInvalidArgument(\sprintf(
671
                $message ?: 'Expected a value to be an IP. Got: %s',
672
                static::valueToString($value)
673
            ));
674
        }
675
    }
676
677
    /**
678
     * @param mixed  $value
@@ 683-691 (lines=9) @@
680
     *
681
     * @throws InvalidArgumentException
682
     */
683
    public static function ipv4($value, $message = '')
684
    {
685
        if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
686
            static::reportInvalidArgument(\sprintf(
687
                $message ?: 'Expected a value to be an IPv4. Got: %s',
688
                static::valueToString($value)
689
            ));
690
        }
691
    }
692
693
    /**
694
     * @param mixed  $value
@@ 699-707 (lines=9) @@
696
     *
697
     * @throws InvalidArgumentException
698
     */
699
    public static function ipv6($value, $message = '')
700
    {
701
        if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
702
            static::reportInvalidArgument(\sprintf(
703
                $message ?: 'Expected a value to be an IPv6. Got: %s',
704
                static::valueToString($value)
705
            ));
706
        }
707
    }
708
709
    /**
710
     * @psalm-pure
@@ 717-725 (lines=9) @@
714
     *
715
     * @throws InvalidArgumentException
716
     */
717
    public static function url($value, $message = '')
718
    {
719
        if (false === \filter_var($value, FILTER_VALIDATE_URL)) {
720
            static::reportInvalidArgument(\sprintf(
721
                $message ?: 'Expected a value to be a valid URL. Got %s',
722
                static::valueToString($value)
723
            ));
724
        }
725
    }
726
727
    /**
728
     * @param mixed  $value
@@ 733-741 (lines=9) @@
730
     *
731
     * @throws InvalidArgumentException
732
     */
733
    public static function email($value, $message = '')
734
    {
735
        if (false === \filter_var($value, FILTER_VALIDATE_EMAIL)) {
736
            static::reportInvalidArgument(\sprintf(
737
                $message ?: 'Expected a value to be a valid e-mail address. Got: %s',
738
                static::valueToString($value)
739
            ));
740
        }
741
    }
742
743
    /**
744
     * Does non strict comparisons on the items, so ['3', 3] will not pass the assertion.