@@ -22,15 +22,19 @@ discard block |
||
22 | 22 | |
23 | 23 | $type = $matches[2][$key]; $name = $matches[3][$key]; $contents = ($matches[4][$key] ?? ''); |
24 | 24 | |
25 | - if (!preg_match(REGEX_TEMPLATE_ITEM_NAME, $name)) continue; |
|
25 | + if (!preg_match(REGEX_TEMPLATE_ITEM_NAME, $name)) { |
|
26 | + continue; |
|
27 | + } |
|
26 | 28 | |
27 | 29 | $this->contents = str_replace($match, ('{ ' . $type . ':' . $name . ' / }'), $this->contents); |
28 | 30 | |
29 | - if ($type === 'block') $this->blocks[$name] = (new Block($contents))->$toggle(); |
|
30 | - |
|
31 | - else if ($type === 'for') $this->loops[$name] = new Loop($contents); |
|
32 | - |
|
33 | - else if ($type === 'widget') $this->widgets[] = $name; |
|
31 | + if ($type === 'block') { |
|
32 | + $this->blocks[$name] = (new Block($contents))->$toggle(); |
|
33 | + } else if ($type === 'for') { |
|
34 | + $this->loops[$name] = new Loop($contents); |
|
35 | + } else if ($type === 'widget') { |
|
36 | + $this->widgets[] = $name; |
|
37 | + } |
|
34 | 38 | } |
35 | 39 | } |
36 | 40 | |
@@ -48,7 +52,9 @@ discard block |
||
48 | 52 | |
49 | 53 | foreach ($matches[1] as $index => $name) { |
50 | 54 | |
51 | - if (!preg_match(REGEX_TEMPLATE_ITEM_NAME, $name)) continue; |
|
55 | + if (!preg_match(REGEX_TEMPLATE_ITEM_NAME, $name)) { |
|
56 | + continue; |
|
57 | + } |
|
52 | 58 | |
53 | 59 | $elementaries['stack'][$name] = false; |
54 | 60 | } |
@@ -68,29 +74,39 @@ discard block |
||
68 | 74 | |
69 | 75 | public function __clone() { |
70 | 76 | |
71 | - foreach ($this->blocks as $name => $block) $this->blocks[$name] = clone $block; |
|
77 | + foreach ($this->blocks as $name => $block) { |
|
78 | + $this->blocks[$name] = clone $block; |
|
79 | + } |
|
72 | 80 | |
73 | - foreach ($this->loops as $name => $loop) $this->loops[$name] = clone $loop; |
|
81 | + foreach ($this->loops as $name => $loop) { |
|
82 | + $this->loops[$name] = clone $loop; |
|
83 | + } |
|
74 | 84 | } |
75 | 85 | |
76 | 86 | # Setter |
77 | 87 | |
78 | 88 | public function __set(string $name, $value) { |
79 | 89 | |
80 | - if ($value instanceof Block) $this->block($name, $value); |
|
81 | - |
|
82 | - else if (is_array($value)) $this->loop($name, $value); |
|
83 | - |
|
84 | - else if (is_scalar($value)) $this->set($name, $value); |
|
90 | + if ($value instanceof Block) { |
|
91 | + $this->block($name, $value); |
|
92 | + } else if (is_array($value)) { |
|
93 | + $this->loop($name, $value); |
|
94 | + } else if (is_scalar($value)) { |
|
95 | + $this->set($name, $value); |
|
96 | + } |
|
85 | 97 | } |
86 | 98 | |
87 | 99 | # Set block |
88 | 100 | |
89 | 101 | public function block(string $name, Block $block = null) { |
90 | 102 | |
91 | - if (!isset($this->blocks[$name])) return ((null === $block) ? new Block() : $this); |
|
103 | + if (!isset($this->blocks[$name])) { |
|
104 | + return ((null === $block) ? new Block() : $this); |
|
105 | + } |
|
92 | 106 | |
93 | - if (null === $block) return $this->blocks[$name]; |
|
107 | + if (null === $block) { |
|
108 | + return $this->blocks[$name]; |
|
109 | + } |
|
94 | 110 | |
95 | 111 | $this->blocks[$name] = $block; |
96 | 112 | |
@@ -103,9 +119,13 @@ discard block |
||
103 | 119 | |
104 | 120 | public function loop(string $name, array $range = null) { |
105 | 121 | |
106 | - if (!isset($this->loops[$name])) return ((null === $range) ? new Loop() : $this); |
|
122 | + if (!isset($this->loops[$name])) { |
|
123 | + return ((null === $range) ? new Loop() : $this); |
|
124 | + } |
|
107 | 125 | |
108 | - if (null === $range) return $this->loops[$name]; |
|
126 | + if (null === $range) { |
|
127 | + return $this->loops[$name]; |
|
128 | + } |
|
109 | 129 | |
110 | 130 | $this->loops[$name]->range($range); |
111 | 131 | |
@@ -118,7 +138,9 @@ discard block |
||
118 | 138 | |
119 | 139 | public function set(string $name, string $value) { |
120 | 140 | |
121 | - if (isset($this->variables[$name])) $this->variables[$name] = $value; |
|
141 | + if (isset($this->variables[$name])) { |
|
142 | + $this->variables[$name] = $value; |
|
143 | + } |
|
122 | 144 | |
123 | 145 | return $this; |
124 | 146 | } |
@@ -127,7 +149,9 @@ discard block |
||
127 | 149 | |
128 | 150 | public function contents() { |
129 | 151 | |
130 | - if (!$this->enabled) return ''; |
|
152 | + if (!$this->enabled) { |
|
153 | + return ''; |
|
154 | + } |
|
131 | 155 | |
132 | 156 | $this->enabled = false; $insertions = []; |
133 | 157 |