1 | <?php declare(strict_types=1); |
||
15 | class Structure extends AbstractIterable |
||
16 | { |
||
17 | /** array Supported character group types */ |
||
18 | const CG_TYPES = [ |
||
19 | FixedVariableCG::class, |
||
20 | VariableFixedCG::class, |
||
21 | VariableCG::class, |
||
22 | FixedCG::class, |
||
23 | ]; |
||
24 | |||
25 | /** @var AbstractCG[] */ |
||
26 | public $groups = []; |
||
27 | |||
28 | /** @var string Input string */ |
||
29 | public $string; |
||
30 | |||
31 | /** |
||
32 | * Create string character group structure from string string. |
||
33 | * |
||
34 | * @param string $input Input string for string character group structure |
||
35 | */ |
||
36 | 21 | public function __construct(string $input) |
|
54 | |||
55 | /** |
||
56 | * Compare structure character groups. |
||
57 | * |
||
58 | * @param Structure $structure Compared string structure group |
||
59 | * |
||
60 | * @return int Comparison result |
||
61 | */ |
||
62 | 18 | public function compare(Structure $structure): int |
|
91 | |||
92 | /** |
||
93 | * Get longest common prefix between strings. |
||
94 | * |
||
95 | * @param Structure $compared Compared character group structure |
||
96 | * |
||
97 | * @return string Strings Longest common prefix or empty string |
||
98 | * |
||
99 | */ |
||
100 | 3 | public function getCommonPrefix(Structure $compared) |
|
126 | |||
127 | /** |
||
128 | * Define shortest structure. |
||
129 | * |
||
130 | * @param Structure $compared Structure to compare |
||
131 | * |
||
132 | * @return Structure Shortest structure |
||
133 | */ |
||
134 | 3 | private function getShortestStructure(Structure $compared): Structure |
|
138 | |||
139 | /** |
||
140 | * Define if string does not match any of the passed character groups. |
||
141 | * |
||
142 | * @param string $string String for comparison |
||
143 | * @param AbstractCG $initialGroup Initial character group |
||
144 | * @param AbstractCG $comparedGroup Compared character group |
||
145 | * |
||
146 | * @return bool True if string not matching any of character groups |
||
147 | */ |
||
148 | 3 | private function isStringNotMatchingAnyCG(string $string, AbstractCG $initialGroup, AbstractCG $comparedGroup): bool |
|
152 | |||
153 | /** |
||
154 | * @return string Structure input string |
||
155 | */ |
||
156 | 2 | public function getString(): string |
|
160 | } |
||
161 |