Abstract Class Yiisoft\Strings\AbstractCombinedRegexp
| Inheritance | Yiisoft\ |
|---|---|
| Subclasses | Yiisoft\ |
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
| Method | Description | Defined By |
|---|---|---|
| getCompiledPattern() | Yiisoft\ |
|
| getFlags() | Yiisoft\ |
|
| getMatchingPattern() | Returns pattern that matches the given string. | Yiisoft\ |
| getMatchingPatternPosition() | Returns position of the pattern that matches the given string. | Yiisoft\ |
| getPatterns() | Yiisoft\ |
|
| matches() | Returns true whether the given string matches any of the patterns, false - otherwise. |
Yiisoft\ |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| throwFailedMatchException() | Yiisoft\ |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| QUOTE_REPLACER | '\/' | Yiisoft\ |
|
| REGEXP_DELIMITER | '/' | Yiisoft\ |
Method Details
| public abstract string getCompiledPattern ( ) | ||
| return | string |
The compiled pattern. |
|---|---|---|
abstract public function getCompiledPattern(): string;
| public abstract string getFlags ( ) | ||
| return | string |
Flags to apply to all regular expressions. |
|---|---|---|
abstract public function getFlags(): string;
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;
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;
| public abstract string[] getPatterns ( ) | ||
| return | string[] |
Regular expressions to combine. |
|---|---|---|
abstract public function getPatterns(): array;
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;
| 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,
),
);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.