@@ 13-34 (lines=22) @@ | ||
10 | * |
|
11 | * @author Vitaly Egorov <[email protected]> |
|
12 | */ |
|
13 | class FixedCG extends AbstractCharacterGroup |
|
14 | { |
|
15 | /** string Character group matching regexp pattern matching group name */ |
|
16 | const PATTERN_GROUP = 'fixed'; |
|
17 | ||
18 | /** string Regular expression matching character group */ |
|
19 | const PATTERN_REGEXP = '[^{}]+'; |
|
20 | ||
21 | /** string Character group matching regexp pattern */ |
|
22 | const PATTERN = '(?<'.self::PATTERN_GROUP.'>'.self::PATTERN_REGEXP.')'; |
|
23 | ||
24 | /** |
|
25 | * @inheritdoc |
|
26 | */ |
|
27 | protected function compareLength(AbstractCharacterGroup $group): int |
|
28 | { |
|
29 | /** |
|
30 | * Shorter fixed character group has higher priority |
|
31 | */ |
|
32 | return $group->length <=> $this->length; |
|
33 | } |
|
34 | } |
|
35 |
@@ 13-34 (lines=22) @@ | ||
10 | * |
|
11 | * @author Vitaly Egorov <[email protected]> |
|
12 | */ |
|
13 | class VariableCG extends AbstractCharacterGroup |
|
14 | { |
|
15 | /** string Character group matching regexp pattern matching group name */ |
|
16 | const PATTERN_GROUP = 'variable'; |
|
17 | ||
18 | /** string Regular expression matching character group */ |
|
19 | const PATTERN_REGEXP = '{.*?}'; |
|
20 | ||
21 | /** string Character group matching regexp pattern */ |
|
22 | const PATTERN = '(?<'.self::PATTERN_GROUP.'>'.self::PATTERN_REGEXP.')'; |
|
23 | ||
24 | /** |
|
25 | * @inheritdoc |
|
26 | */ |
|
27 | protected function compareLength(AbstractCharacterGroup $group): int |
|
28 | { |
|
29 | /** |
|
30 | * Longer variable character group has higher priority |
|
31 | */ |
|
32 | return $this->length <=> $group->length; |
|
33 | } |
|
34 | } |
|
35 |