1 | <?php |
||
16 | class Parser |
||
17 | { |
||
18 | |||
19 | const MAGIC_COMMENT_PREFIX = '# HAPHPROXY_COMMENT'; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $filePath; |
||
25 | |||
26 | |||
27 | /** |
||
28 | * Parser constructor. |
||
29 | * |
||
30 | * @param string $filePath |
||
31 | * |
||
32 | * @throws FileNotFoundException if the specified file could not be found or is not readable |
||
33 | */ |
||
34 | public function __construct($filePath) |
||
42 | |||
43 | |||
44 | /** |
||
45 | * @return Configuration |
||
46 | */ |
||
47 | public function parse() |
||
93 | |||
94 | |||
95 | /** |
||
96 | * Reads the configuration and yields one line at a time |
||
97 | * |
||
98 | * @return \Generator |
||
99 | */ |
||
100 | private function getConfigurationLines() |
||
108 | |||
109 | |||
110 | /** |
||
111 | * @return \Generator |
||
112 | */ |
||
113 | private function getNormalizedConfigurationLines() |
||
119 | |||
120 | |||
121 | /** |
||
122 | * @param string $line |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | private static function normalizeLine($line) |
||
130 | |||
131 | |||
132 | /** |
||
133 | * @param string $line |
||
134 | * |
||
135 | * @return bool if the line is a comment |
||
136 | */ |
||
137 | private static function isComment($line) |
||
141 | |||
142 | |||
143 | /** |
||
144 | * @param string $line |
||
145 | * |
||
146 | * @return bool whether the line is a magic comment |
||
147 | */ |
||
148 | private static function isMagicComment($line) |
||
152 | |||
153 | |||
154 | /** |
||
155 | * @param string $line |
||
156 | * |
||
157 | * @return string |
||
158 | */ |
||
159 | private static function parseMagicComment($line) |
||
163 | |||
164 | |||
165 | /** |
||
166 | * @param string $line |
||
167 | * |
||
168 | * @return Parameter |
||
169 | */ |
||
170 | private static function parseParameter($line) |
||
184 | |||
185 | } |
||
186 |