| Total Complexity | 5 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | final class InlineParserMatch |
||
| 17 | { |
||
| 18 | /** @var string */ |
||
| 19 | private $regex; |
||
| 20 | |||
| 21 | 2880 | private function __construct(string $regex) |
|
| 24 | 2880 | } |
|
| 25 | |||
| 26 | /** |
||
| 27 | * @internal |
||
| 28 | */ |
||
| 29 | 2904 | public function getRegex(): string |
|
| 30 | { |
||
| 31 | 2904 | return $this->regex; |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Match the given string (case-insensitive) |
||
| 36 | */ |
||
| 37 | 2880 | public static function string(string $str): self |
|
| 38 | { |
||
| 39 | 2880 | return new self('/' . \preg_quote($str, '/') . '/i'); |
|
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Match any of the given strings (case-insensitive) |
||
| 44 | */ |
||
| 45 | 2880 | public static function oneOf(string ...$str): self |
|
| 46 | { |
||
| 47 | 1920 | return new self('/' . \implode('|', \array_map(static function (string $str): string { |
|
| 48 | 2880 | return \preg_quote($str, '/'); |
|
| 49 | 2880 | }, $str)) . '/i'); |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Match a partial regular expression without starting/ending delimiters, anchors, or flags |
||
| 54 | */ |
||
| 55 | 2880 | public static function regex(string $regex): self |
|
| 58 | } |
||
| 59 | } |
||
| 60 |