Code Duplication    Length = 19-19 lines in 2 locations

src/Assert.php 2 locations

@@ 985-1003 (lines=19) @@
982
     * @return Assert
983
     * @throws AssertionFailedException
984
     */
985
    public function startsWith($needle, $message = null, $propertyPath = null, $encoding = 'utf8')
986
    {
987
        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
988
        {
989
            return $this;
990
        }
991
        $this->string($message, $propertyPath);
992
        if ( mb_strpos($this->value, $needle, null, $encoding) !== 0 )
993
        {
994
            $message     = sprintf(
995
                $message ?: 'Value "%s" does not start with "%s".',
996
                $this->stringify($this->value),
997
                $this->stringify($needle)
998
            );
999
            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1000
            throw $this->createException($message, self::INVALID_STRING_START, $propertyPath, $constraints);
1001
        }
1002
        return $this;
1003
    }
1004
1005
    /**
1006
     * Assert that string ends with a sequence of chars.
@@ 1046-1064 (lines=19) @@
1043
     * @return Assert
1044
     * @throws AssertionFailedException
1045
     */
1046
    public function contains($needle, $message = null, $propertyPath = null, $encoding = 'utf8')
1047
    {
1048
        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1049
        {
1050
            return $this;
1051
        }
1052
        $this->string($message, $propertyPath);
1053
        if ( mb_strpos($this->value, $needle, null, $encoding) === false )
1054
        {
1055
            $message     = sprintf(
1056
                $message ?: 'Value "%s" does not contain "%s".',
1057
                $this->stringify($this->value),
1058
                $this->stringify($needle)
1059
            );
1060
            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1061
            throw $this->createException($message, self::INVALID_STRING_CONTAINS, $propertyPath, $constraints);
1062
        }
1063
        return $this;
1064
    }
1065
1066
    /**
1067
     * Assert that value is in array of choices.