1 | <?php |
||
14 | class Normaliser |
||
15 | { |
||
16 | /** |
||
17 | * @var StringIterator |
||
18 | */ |
||
19 | private $string; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $normalisedString = ''; |
||
25 | |||
26 | /** |
||
27 | * Normaliser constructor. |
||
28 | * |
||
29 | * @param string $zone |
||
30 | */ |
||
31 | 13 | public function __construct(string $zone) |
|
38 | |||
39 | /** |
||
40 | * @param string $zone |
||
41 | * |
||
42 | * @return string |
||
43 | * |
||
44 | * @throws ParseException |
||
45 | */ |
||
46 | 13 | public static function normalise(string $zone): string |
|
50 | |||
51 | /** |
||
52 | * @return string |
||
53 | * |
||
54 | * @throws ParseException |
||
55 | */ |
||
56 | 13 | public function process(): string |
|
69 | |||
70 | /** |
||
71 | * Ignores the comment section. |
||
72 | */ |
||
73 | 13 | private function handleComment(): void |
|
83 | |||
84 | /** |
||
85 | * Handle text inside of double quotations. When this function is called, the String pointer MUST be at the |
||
86 | * double quotation mark. |
||
87 | * |
||
88 | * @throws ParseException |
||
89 | */ |
||
90 | 13 | private function handleTxt(): void |
|
115 | |||
116 | /** |
||
117 | * Move multi-line records onto single line. |
||
118 | * |
||
119 | * @throws ParseException |
||
120 | */ |
||
121 | 13 | private function handleMultiline(): void |
|
148 | |||
149 | /** |
||
150 | * Remove superfluous whitespace characters from string. |
||
151 | * |
||
152 | * @throws \UnexpectedValueException |
||
153 | */ |
||
154 | 10 | private function removeWhitespace(): void |
|
171 | |||
172 | /** |
||
173 | * Add current entry to normalisedString and moves iterator to next entry. |
||
174 | */ |
||
175 | 13 | private function append() |
|
180 | } |
||
181 |