1 | <?php |
||
24 | class Compiler |
||
25 | { |
||
26 | /** |
||
27 | * The string to match as a starting multi-line directive. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | private $startMultiLine; |
||
32 | |||
33 | /** |
||
34 | * The string to match as an ending multi-line directive. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | private $endMultiLine; |
||
39 | |||
40 | /** |
||
41 | * The string to match a simple Directive. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | private $simpleDirective; |
||
46 | |||
47 | /** |
||
48 | * The string to match an inclusion Directive. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | private $inclusionDirective; |
||
53 | |||
54 | /** |
||
55 | * An absolute path prefix. |
||
56 | * |
||
57 | * The compiler needs an absolute path prefix to find included files set with a relative path |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | private $prefix; |
||
62 | |||
63 | /** |
||
64 | * Constructor. |
||
65 | * |
||
66 | * @param string $startMultiLine match as a starting multi-line directive |
||
67 | * @param string $endMultiLine match as an ending multi-line directive |
||
68 | * @param string $simpleDirective match a simple directive |
||
69 | * @param string $inclusionDirective match an inclusion directive |
||
70 | */ |
||
71 | 7 | public function __construct($startMultiLine, $endMultiLine, $simpleDirective, $inclusionDirective) |
|
78 | |||
79 | /** |
||
80 | * Gets an absolute path prefix. |
||
81 | * |
||
82 | * @param string an absolute path prefix |
||
83 | */ |
||
84 | 2 | public function getPrefix() |
|
88 | |||
89 | /** |
||
90 | * Sets an absolute path prefix. |
||
91 | * |
||
92 | * @param string $prefix an absolute path prefix |
||
93 | */ |
||
94 | 7 | public function setPrefix($prefix = '') |
|
100 | |||
101 | /** |
||
102 | * Does a nested array of lines depending on container Directives. |
||
103 | * |
||
104 | * @param array $activeConfig a clean config array of lines |
||
105 | * @param string $context the context name |
||
106 | * @param string $value an optional context value |
||
107 | * |
||
108 | * @return Directive\BlockDirective a full context of directives |
||
109 | */ |
||
110 | 10 | public function doCompile($activeConfig, $context = 'main', $value = '') |
|
121 | |||
122 | /** |
||
123 | * Looks for a container directive. |
||
124 | * |
||
125 | * @param array $activeConfig a clean config array of directives |
||
126 | * @param string $lineConfig a line |
||
127 | * |
||
128 | * @return Directive\DirectiveInterface a directive or a container of directives |
||
129 | * |
||
130 | * @throws Exception\InvalidConfigException if a simple directive has invalid syntax |
||
131 | */ |
||
132 | 7 | private function subCompile(&$activeConfig, $lineConfig) |
|
144 | |||
145 | /** |
||
146 | * Finds the end of a container directive. |
||
147 | * |
||
148 | * @param string $context a container's name |
||
149 | * @param string $contextValue a container's value |
||
150 | * @param array $activeConfig a clean config array of lines |
||
151 | * |
||
152 | * @return Directive\BlockDirective a container of directives |
||
153 | * |
||
154 | * @throws Exception\InvalidConfigException if a container does not end correctly |
||
155 | */ |
||
156 | 6 | private function findEndingKey($context, $contextValue, &$activeConfig) |
|
173 | |||
174 | /** |
||
175 | * Builds a BlockDirective. |
||
176 | * |
||
177 | * @param string $context a container's name |
||
178 | * @param string $contextValue a container's value |
||
179 | * @param array $lines an array of directives |
||
180 | * |
||
181 | * @return Directive\BlockDirective the BlockDirective |
||
182 | */ |
||
183 | 8 | private function buildBlockDirective($context, $contextValue, $lines) |
|
192 | |||
193 | /** |
||
194 | * Build a SimpleDirective or an InclusionDirective. |
||
195 | * |
||
196 | * Remember that inclusion are parsed as simple directives but are block directives |
||
197 | * |
||
198 | * @see Directive\InclusionDirective Inclusion Doc |
||
199 | * |
||
200 | * @param string $key a directive's name |
||
201 | * @param string $value a directive's value |
||
202 | * |
||
203 | * @return Directive\SimpleDirective|Directive\InclusionDirective the Directive |
||
204 | */ |
||
205 | 6 | private function buildSimpleDirective($key, $value) |
|
213 | } |
||
214 |