Code Duplication    Length = 10-11 lines in 4 locations

src/Assert.php 4 locations

@@ 517-526 (lines=10) @@
514
        }
515
    }
516
517
    public static function endsWith($value, $suffix, $message = '')
518
    {
519
        if ($suffix !== substr($value, -static::strlen($suffix))) {
520
            throw new InvalidArgumentException(sprintf(
521
                $message ?: 'Expected a value to end with %2$s. Got: %s',
522
                static::valueToString($value),
523
                static::valueToString($suffix)
524
            ));
525
        }
526
    }
527
528
    public static function regex($value, $pattern, $message = '')
529
    {
@@ 672-682 (lines=11) @@
669
        }
670
    }
671
672
    public static function file($value, $message = '')
673
    {
674
        static::fileExists($value, $message);
675
676
        if (!is_file($value)) {
677
            throw new InvalidArgumentException(sprintf(
678
                $message ?: 'The path %s is not a file.',
679
                static::valueToString($value)
680
            ));
681
        }
682
    }
683
684
    public static function directory($value, $message = '')
685
    {
@@ 684-694 (lines=11) @@
681
        }
682
    }
683
684
    public static function directory($value, $message = '')
685
    {
686
        static::fileExists($value, $message);
687
688
        if (!is_dir($value)) {
689
            throw new InvalidArgumentException(sprintf(
690
                $message ?: 'The path %s is no directory.',
691
                static::valueToString($value)
692
            ));
693
        }
694
    }
695
696
    public static function readable($value, $message = '')
697
    {
@@ 737-746 (lines=10) @@
734
        }
735
    }
736
737
    public static function implementsInterface($value, $interface, $message = '')
738
    {
739
        if (!in_array($interface, class_implements($value))) {
740
            throw new InvalidArgumentException(sprintf(
741
                $message ?: 'Expected an implementation of %2$s. Got: %s',
742
                static::valueToString($value),
743
                static::valueToString($interface)
744
            ));
745
        }
746
    }
747
748
    public static function propertyExists($classOrObject, $property, $message = '')
749
    {