0 follower

Abstract Class Yiisoft\Strings\AbstractCombinedRegexp

InheritanceYiisoft\Strings\AbstractCombinedRegexp
SubclassesYiisoft\Strings\CombinedRegexp, Yiisoft\Strings\MemoizedCombinedRegexp

CombinedRegexp optimizes matching of multiple regular expressions.

Read more about the concept in {@see https://nikic.github.io/2014/02/18/Fast-request-routing-using-regular-expressions.html}.

Public Methods

Hide inherited methods

Method Description Defined By
getCompiledPattern() Yiisoft\Strings\AbstractCombinedRegexp
getFlags() Yiisoft\Strings\AbstractCombinedRegexp
getMatchingPattern() Returns pattern that matches the given string. Yiisoft\Strings\AbstractCombinedRegexp
getMatchingPatternPosition() Returns position of the pattern that matches the given string. Yiisoft\Strings\AbstractCombinedRegexp
getPatterns() Yiisoft\Strings\AbstractCombinedRegexp
matches() Returns true whether the given string matches any of the patterns, false - otherwise. Yiisoft\Strings\AbstractCombinedRegexp

Constants

Hide inherited constants

Constant Value Description Defined By
QUOTE_REPLACER '\/' Yiisoft\Strings\AbstractCombinedRegexp
REGEXP_DELIMITER '/' Yiisoft\Strings\AbstractCombinedRegexp

Method Details

Hide inherited methods

getCompiledPattern() public abstract method

public abstract string getCompiledPattern ( )
return string

The compiled pattern.

                abstract public function getCompiledPattern(): string;

            
getFlags() public abstract method

public abstract string getFlags ( )
return string

Flags to apply to all regular expressions.

                abstract public function getFlags(): string;

            
getMatchingPattern() public abstract method

Returns pattern that matches the given string.

public abstract string getMatchingPattern ( string $string )
$string string
throws Exception

if the string does not match any of the patterns.

                abstract public function getMatchingPattern(string $string): string;

            
getMatchingPatternPosition() public abstract method

Returns position of the pattern that matches the given string.

public abstract integer getMatchingPatternPosition ( string $string )
$string string
throws Exception

if the string does not match any of the patterns.

                abstract public function getMatchingPatternPosition(string $string): int;

            
getPatterns() public abstract method

public abstract string[] getPatterns ( )
return string[]

Regular expressions to combine.

                abstract public function getPatterns(): array;

            
matches() public abstract method

Returns true whether the given string matches any of the patterns, false - otherwise.

public abstract boolean matches ( string $string )
$string string

                abstract public function matches(string $string): bool;

            
throwFailedMatchException() protected method

protected void throwFailedMatchException ( string $string )
$string string
throws Exception

                protected function throwFailedMatchException(string $string): void
{
    throw new Exception(
        sprintf(
            'Failed to match pattern "%s" with string "%s".',
            $this->getCompiledPattern(),
            $string,
        )
    );
}