@@ -31,15 +31,19 @@ discard block |
||
31 | 31 | |
32 | 32 | $type = $matches[2][$key]; $name = $matches[3][$key]; $contents = ($matches[4][$key] ?? ''); |
33 | 33 | |
34 | - if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) continue; |
|
34 | + if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) { |
|
35 | + continue; |
|
36 | + } |
|
35 | 37 | |
36 | 38 | $this->contents = str_replace($match, ('{ ' . $type . ':' . $name . ' / }'), $this->contents); |
37 | 39 | |
38 | - if ($type === 'block') $this->blocks[$name] = (new Block($contents))->$toggle(); |
|
39 | - |
|
40 | - else if ($type === 'for') $this->loops[$name] = new Loop($contents); |
|
41 | - |
|
42 | - else if ($type === 'widget') $this->widgets[] = $name; |
|
40 | + if ($type === 'block') { |
|
41 | + $this->blocks[$name] = (new Block($contents))->$toggle(); |
|
42 | + } else if ($type === 'for') { |
|
43 | + $this->loops[$name] = new Loop($contents); |
|
44 | + } else if ($type === 'widget') { |
|
45 | + $this->widgets[] = $name; |
|
46 | + } |
|
43 | 47 | } |
44 | 48 | } |
45 | 49 | |
@@ -59,7 +63,9 @@ discard block |
||
59 | 63 | |
60 | 64 | foreach ($matches[1] as $index => $name) { |
61 | 65 | |
62 | - if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) continue; |
|
66 | + if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) { |
|
67 | + continue; |
|
68 | + } |
|
63 | 69 | |
64 | 70 | $elementaries['stack'][$name] = false; |
65 | 71 | } |
@@ -143,11 +149,17 @@ discard block |
||
143 | 149 | |
144 | 150 | public function __clone() { |
145 | 151 | |
146 | - foreach ($this->blocks as $name => $block) $this->blocks[$name] = clone $block; |
|
152 | + foreach ($this->blocks as $name => $block) { |
|
153 | + $this->blocks[$name] = clone $block; |
|
154 | + } |
|
147 | 155 | |
148 | - foreach ($this->loops as $name => $loop) $this->loops[$name] = clone $loop; |
|
156 | + foreach ($this->loops as $name => $loop) { |
|
157 | + $this->loops[$name] = clone $loop; |
|
158 | + } |
|
149 | 159 | |
150 | - foreach ($this->items as $name => $item) $this->items[$name] = clone $item; |
|
160 | + foreach ($this->items as $name => $item) { |
|
161 | + $this->items[$name] = clone $item; |
|
162 | + } |
|
151 | 163 | } |
152 | 164 | |
153 | 165 | /** |
@@ -158,11 +170,13 @@ discard block |
||
158 | 170 | |
159 | 171 | public function set(string $name, $value) : Block { |
160 | 172 | |
161 | - if ($value instanceof Block) $this->setBlock($name, $value); |
|
162 | - |
|
163 | - else if (is_array($value)) $this->setLoop($name, $value); |
|
164 | - |
|
165 | - else if (is_scalar($value)) $this->setVar($name, $value); |
|
173 | + if ($value instanceof Block) { |
|
174 | + $this->setBlock($name, $value); |
|
175 | + } else if (is_array($value)) { |
|
176 | + $this->setLoop($name, $value); |
|
177 | + } else if (is_scalar($value)) { |
|
178 | + $this->setVar($name, $value); |
|
179 | + } |
|
166 | 180 | |
167 | 181 | # ------------------------ |
168 | 182 | |
@@ -177,7 +191,9 @@ discard block |
||
177 | 191 | |
178 | 192 | public function setArray(array $components) : Block { |
179 | 193 | |
180 | - foreach ($components as $name => $component) $this->set($name, $component); |
|
194 | + foreach ($components as $name => $component) { |
|
195 | + $this->set($name, $component); |
|
196 | + } |
|
181 | 197 | |
182 | 198 | return $this; |
183 | 199 | } |
@@ -190,7 +206,9 @@ discard block |
||
190 | 206 | |
191 | 207 | public function setBlock(string $name, Block $block) : Block { |
192 | 208 | |
193 | - if (isset($this->blocks[$name])) $this->blocks[$name] = $block; |
|
209 | + if (isset($this->blocks[$name])) { |
|
210 | + $this->blocks[$name] = $block; |
|
211 | + } |
|
194 | 212 | |
195 | 213 | return $this; |
196 | 214 | } |
@@ -203,7 +221,9 @@ discard block |
||
203 | 221 | |
204 | 222 | public function setLoop(string $name, array $items) : Block { |
205 | 223 | |
206 | - if (isset($this->loops[$name])) $this->loops[$name]->setItems($items); |
|
224 | + if (isset($this->loops[$name])) { |
|
225 | + $this->loops[$name]->setItems($items); |
|
226 | + } |
|
207 | 227 | |
208 | 228 | return $this; |
209 | 229 | } |
@@ -216,7 +236,9 @@ discard block |
||
216 | 236 | |
217 | 237 | public function setVar(string $name, string $value) : Block { |
218 | 238 | |
219 | - if (isset($this->variables[$name])) $this->variables[$name] = $value; |
|
239 | + if (isset($this->variables[$name])) { |
|
240 | + $this->variables[$name] = $value; |
|
241 | + } |
|
220 | 242 | |
221 | 243 | return $this; |
222 | 244 | } |
@@ -298,7 +320,9 @@ discard block |
||
298 | 320 | |
299 | 321 | public function getContents() : string { |
300 | 322 | |
301 | - if (!$this->enabled) return ''; |
|
323 | + if (!$this->enabled) { |
|
324 | + return ''; |
|
325 | + } |
|
302 | 326 | |
303 | 327 | # Lock the block |
304 | 328 |
@@ -28,7 +28,9 @@ discard block |
||
28 | 28 | |
29 | 29 | public function __clone() { |
30 | 30 | |
31 | - foreach ($this->items as $name => $item) $this->items[$name] = clone $item; |
|
31 | + foreach ($this->items as $name => $item) { |
|
32 | + $this->items[$name] = clone $item; |
|
33 | + } |
|
32 | 34 | } |
33 | 35 | |
34 | 36 | /** |
@@ -52,7 +54,9 @@ discard block |
||
52 | 54 | |
53 | 55 | public function addItems(array $items) : Group { |
54 | 56 | |
55 | - foreach ($items as $item) if ($item instanceof Block) $this->addItem($item); |
|
57 | + foreach ($items as $item) { |
|
58 | + if ($item instanceof Block) $this->addItem($item); |
|
59 | + } |
|
56 | 60 | |
57 | 61 | return $this; |
58 | 62 | } |
@@ -111,7 +115,9 @@ discard block |
||
111 | 115 | |
112 | 116 | # Process items |
113 | 117 | |
114 | - foreach ($this->items as $block) $contents .= $block->getContents(); |
|
118 | + foreach ($this->items as $block) { |
|
119 | + $contents .= $block->getContents(); |
|
120 | + } |
|
115 | 121 | |
116 | 122 | # ------------------------ |
117 | 123 |