| Total Complexity | 7 |
| Total Lines | 52 |
| 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 | 2886 | private function __construct(string $regex) |
|
| 24 | 2886 | } |
|
| 25 | |||
| 26 | /** |
||
| 27 | * @internal |
||
| 28 | */ |
||
| 29 | 2913 | public function getRegex(): string |
|
| 30 | { |
||
| 31 | 2913 | return '/' . $this->regex . '/i'; |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Match the given string (case-insensitive) |
||
| 36 | */ |
||
| 37 | 2886 | public static function string(string $str): self |
|
| 38 | { |
||
| 39 | 2886 | return new self(\preg_quote($str, '/')); |
|
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Match any of the given strings (case-insensitive) |
||
| 44 | */ |
||
| 45 | 2886 | public static function oneOf(string ...$str): self |
|
| 46 | { |
||
| 47 | 1924 | return new self(\implode('|', \array_map(static function (string $str): string { |
|
| 48 | 2886 | return \preg_quote($str, '/'); |
|
| 49 | 2886 | }, $str))); |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Match a partial regular expression without starting/ending delimiters, anchors, or flags |
||
| 54 | */ |
||
| 55 | 2886 | public static function regex(string $regex): self |
|
| 58 | } |
||
| 59 | |||
| 60 | 36 | public static function join(self ...$definitions): self |
|
| 61 | { |
||
| 70 |