1 | <?php declare(strict_types=1); |
||
13 | class VariableCG extends AbstractCG |
||
14 | { |
||
15 | /** string Regular expression named filter group */ |
||
16 | const PATTERN_FILTER_GROUP = 'filter'; |
||
17 | |||
18 | /** string Variable string filter pattern */ |
||
19 | const PATTER_FILTER = '/.*?:(?<'.self::PATTERN_FILTER_GROUP.'>[^}]+)/'; |
||
20 | |||
21 | /** string Regular expression named character group group */ |
||
22 | const PATTERN_GROUP = 'variable'; |
||
23 | |||
24 | /** string Regular expression matching character group */ |
||
25 | const PATTERN_REGEXP = '{.*?}'; |
||
26 | |||
27 | /** string Character group matching regexp pattern */ |
||
28 | const PATTERN = '(?<'.self::PATTERN_GROUP.'>'.self::PATTERN_REGEXP.')'; |
||
29 | |||
30 | /** @var string Variable character group filter string */ |
||
31 | protected $filter; |
||
32 | |||
33 | /** |
||
34 | * @inheritdoc |
||
35 | */ |
||
36 | 22 | public function __construct($string, $length = 0) |
|
42 | |||
43 | /** |
||
44 | * Get variable character group filter value. |
||
45 | * |
||
46 | * @return string Filter value or empty string |
||
47 | */ |
||
48 | 22 | protected function getFilter(): string |
|
56 | |||
57 | /** |
||
58 | * Whole variable length string should match. |
||
59 | * |
||
60 | * @inheritdoc |
||
61 | */ |
||
62 | 2 | public function getCommonPrefix(AbstractCG $group): string |
|
71 | |||
72 | /** |
||
73 | * @inheritdoc |
||
74 | */ |
||
75 | 9 | protected function compareLength(AbstractCG $group): int |
|
102 | |||
103 | /** |
||
104 | * @return bool Return true if variable character group has filter |
||
105 | */ |
||
106 | 9 | protected function isFiltered(): bool |
|
110 | } |
||
111 |