1 | <?php |
||
5 | class VariableParser extends AbstractSectionParser |
||
6 | { |
||
7 | use \Karma\Configuration\FilterInputVariable; |
||
8 | |||
9 | const |
||
10 | ASSIGNMENT = '=', |
||
11 | ENV_SEPARATOR = ',', |
||
12 | DEFAULT_ENV = 'default'; |
||
13 | |||
14 | private |
||
15 | $currentVariable, |
||
|
|||
16 | $variables, |
||
17 | $valueFound; |
||
18 | |||
19 | public function __construct() |
||
20 | { |
||
21 | $this->currentVariable = null; |
||
22 | $this->variables = array(); |
||
23 | $this->valueFound = false; |
||
24 | } |
||
25 | |||
26 | protected function parseLine($line) |
||
27 | { |
||
28 | if($this->isACommentLine($line)) |
||
29 | { |
||
30 | return true; |
||
31 | } |
||
32 | |||
33 | $variableName = $this->extractVariableName($line); |
||
34 | |||
35 | if($variableName !== null) |
||
36 | { |
||
37 | return $this->changeCurrentVariable($variableName); |
||
38 | } |
||
39 | |||
40 | $this->parseEnvironmentValue($line); |
||
41 | } |
||
42 | |||
43 | private function extractVariableName($line) |
||
54 | |||
55 | private function checkCurrentVariableState() |
||
56 | { |
||
67 | |||
68 | private function changeCurrentVariable($variableName) |
||
91 | |||
92 | private function parseEnvironmentValue($line) |
||
122 | |||
123 | public function getVariables() |
||
127 | |||
128 | public function setCurrentFile($filePath) |
||
134 | |||
135 | public function endOfFileCheck() |
||
139 | } |
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.