Passed
Branch 0.4.0 (deb4fd)
by Anton
03:02
created
www/engine/Framework/Classes/Dataset/Dataset.php 1 patch
Braces   +28 added lines, -18 removed lines patch added patch discarded remove patch
@@ -34,7 +34,9 @@  discard block
 block discarded – undo
34 34
 
35 35
 		public function addParam(string $name, $default, callable $validator = null) : Dataset {
36 36
 
37
-			if ('' === $name) return $this;
37
+			if ('' === $name) {
38
+				return $this;
39
+			}
38 40
 
39 41
 			$this->data[$name] = $default; $this->defaults[$name] = $default;
40 42
 
@@ -53,7 +55,9 @@  discard block
 block discarded – undo
53 55
 
54 56
 		public function addParams(array $data) : Dataset {
55 57
 
56
-			foreach ($data as $name => $value) if (is_scalar($name)) $this->addParam($name, $value);
58
+			foreach ($data as $name => $value) {
59
+				if (is_scalar($name)) $this->addParam($name, $value);
60
+			}
57 61
 
58 62
 			return $this;
59 63
 		}
@@ -66,16 +70,16 @@  discard block
 block discarded – undo
66 70
 
67 71
 		public function set(string $name, $value) {
68 72
 
69
-			if (!isset($this->validators[$name])) return null;
73
+			if (!isset($this->validators[$name])) {
74
+				return null;
75
+			}
70 76
 
71 77
 			try {
72 78
 
73
-				if (null === ($value = $this->validators[$name]($value))) return false;
74
-
75
-				else { $this->data[$name] = $value; return true; }
76
-			}
77
-
78
-			catch (TypeError $e) { return false; }
79
+				if (null === ($value = $this->validators[$name]($value))) {
80
+					return false;
81
+				} else { $this->data[$name] = $value; return true; }
82
+			} catch (TypeError $e) { return false; }
79 83
 		}
80 84
 
81 85
 		/**
@@ -90,7 +94,9 @@  discard block
 block discarded – undo
90 94
 
91 95
 			foreach ($data as $name => $value) {
92 96
 
93
-				if (null !== ($value = $this->set($name, $value))) $setted[$name] = $value;
97
+				if (null !== ($value = $this->set($name, $value))) {
98
+					$setted[$name] = $value;
99
+				}
94 100
 			}
95 101
 
96 102
 			# ------------------------
@@ -106,16 +112,18 @@  discard block
 block discarded – undo
106 112
 
107 113
 		public function cast(string $name, $value) {
108 114
 
109
-			if (!isset($this->validators[$name])) return null;
115
+			if (!isset($this->validators[$name])) {
116
+				return null;
117
+			}
110 118
 
111 119
 			try {
112 120
 
113
-				if (null !== ($value = $this->validators[$name]($value))) return $value;
114
-
115
-				else return $this->data[$name];
116
-			}
117
-
118
-			catch (TypeError $e) { return $this->data[$name]; }
121
+				if (null !== ($value = $this->validators[$name]($value))) {
122
+					return $value;
123
+				} else {
124
+					return $this->data[$name];
125
+				}
126
+			} catch (TypeError $e) { return $this->data[$name]; }
119 127
 		}
120 128
 
121 129
 		/**
@@ -130,7 +138,9 @@  discard block
 block discarded – undo
130 138
 
131 139
 			foreach ($data as $name => $value) {
132 140
 
133
-				if (null !== ($value = $this->cast($name, $value))) $casted[$name] = $value;
141
+				if (null !== ($value = $this->cast($name, $value))) {
142
+					$casted[$name] = $value;
143
+				}
134 144
 			}
135 145
 
136 146
 			# ------------------------
Please login to merge, or discard this patch.
www/engine/Framework/Classes/Template/Block.php 1 patch
Braces   +50 added lines, -22 removed lines patch added patch discarded remove patch
@@ -33,15 +33,19 @@  discard block
 block discarded – undo
33 33
 
34 34
 				$type = $matches[2][$key]; $name = $matches[3][$key]; $contents = ($matches[4][$key] ?? '');
35 35
 
36
-				if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) continue;
36
+				if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) {
37
+					continue;
38
+				}
37 39
 
38 40
 				$this->contents = str_replace($match, ('{ ' . $type . ':' . $name . ' / }'), $this->contents);
39 41
 
40
-				if ($type === 'block') $this->blocks[$name] = (new Block($contents))->$toggle();
41
-
42
-				else if ($type === 'for') $this->loops[$name] = new Loop($contents);
43
-
44
-				else if ($type === 'widget') $this->widgets[] = $name;
42
+				if ($type === 'block') {
43
+					$this->blocks[$name] = (new Block($contents))->$toggle();
44
+				} else if ($type === 'for') {
45
+					$this->loops[$name] = new Loop($contents);
46
+				} else if ($type === 'widget') {
47
+					$this->widgets[] = $name;
48
+				}
45 49
 			}
46 50
 		}
47 51
 
@@ -61,7 +65,9 @@  discard block
 block discarded – undo
61 65
 
62 66
 				foreach ($matches[1] as $index => $name) {
63 67
 
64
-					if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) continue;
68
+					if (!preg_match(REGEX_TEMPLATE_COMPONENT_NAME, $name)) {
69
+						continue;
70
+					}
65 71
 
66 72
 					$elementaries['stack'][$name] = false;
67 73
 				}
@@ -138,7 +144,9 @@  discard block
 block discarded – undo
138 144
 
139 145
 			# Process items
140 146
 
141
-			foreach ($this->items as $block) $contents .= $block->getContents();
147
+			foreach ($this->items as $block) {
148
+				$contents .= $block->getContents();
149
+			}
142 150
 
143 151
 			# ------------------------
144 152
 
@@ -177,7 +185,9 @@  discard block
 block discarded – undo
177 185
 
178 186
 		public function addItems(array $items) : Block {
179 187
 
180
-			foreach ($items as $item) if ($item instanceof Block) $this->addItem($item);
188
+			foreach ($items as $item) {
189
+				if ($item instanceof Block) $this->addItem($item);
190
+			}
181 191
 
182 192
 			return $this;
183 193
 		}
@@ -203,11 +213,13 @@  discard block
 block discarded – undo
203 213
 
204 214
 		public function set(string $name, $value) : Block {
205 215
 
206
-			if ($value instanceof Block) $this->setBlock($name, $value);
207
-
208
-			else if (is_array($value)) $this->setLoop($name, $value);
209
-
210
-			else if (is_scalar($value)) $this->setVar($name, $value);
216
+			if ($value instanceof Block) {
217
+				$this->setBlock($name, $value);
218
+			} else if (is_array($value)) {
219
+				$this->setLoop($name, $value);
220
+			} else if (is_scalar($value)) {
221
+				$this->setVar($name, $value);
222
+			}
211 223
 
212 224
 			# ------------------------
213 225
 
@@ -222,7 +234,9 @@  discard block
 block discarded – undo
222 234
 
223 235
 		public function setArray(array $components) : Block {
224 236
 
225
-			foreach ($components as $name => $component) $this->set($name, $component);
237
+			foreach ($components as $name => $component) {
238
+				$this->set($name, $component);
239
+			}
226 240
 
227 241
 			return $this;
228 242
 		}
@@ -235,7 +249,9 @@  discard block
 block discarded – undo
235 249
 
236 250
 		public function setBlock(string $name, Block $block) : Block {
237 251
 
238
-			if (isset($this->blocks[$name])) $this->blocks[$name] = $block;
252
+			if (isset($this->blocks[$name])) {
253
+				$this->blocks[$name] = $block;
254
+			}
239 255
 
240 256
 			return $this;
241 257
 		}
@@ -248,7 +264,9 @@  discard block
 block discarded – undo
248 264
 
249 265
 		public function setLoop(string $name, array $items) : Block {
250 266
 
251
-			if (isset($this->loops[$name])) $this->loops[$name]->setItems($items);
267
+			if (isset($this->loops[$name])) {
268
+				$this->loops[$name]->setItems($items);
269
+			}
252 270
 
253 271
 			return $this;
254 272
 		}
@@ -261,7 +279,9 @@  discard block
 block discarded – undo
261 279
 
262 280
 		public function setVar(string $name, string $value) : Block {
263 281
 
264
-			if (isset($this->variables[$name])) $this->variables[$name] = $value;
282
+			if (isset($this->variables[$name])) {
283
+				$this->variables[$name] = $value;
284
+			}
265 285
 
266 286
 			return $this;
267 287
 		}
@@ -374,7 +394,9 @@  discard block
 block discarded – undo
374 394
 
375 395
 		public function getContents() : string {
376 396
 
377
-			if (!$this->enabled) return '';
397
+			if (!$this->enabled) {
398
+				return '';
399
+			}
378 400
 
379 401
 			# Lock the block
380 402
 
@@ -434,11 +456,17 @@  discard block
 block discarded – undo
434 456
 
435 457
 		public function __clone() {
436 458
 
437
-			foreach ($this->blocks as $name => $block) $this->blocks[$name] = clone $block;
459
+			foreach ($this->blocks as $name => $block) {
460
+				$this->blocks[$name] = clone $block;
461
+			}
438 462
 
439
-			foreach ($this->loops as $name => $loop) $this->loops[$name] = clone $loop;
463
+			foreach ($this->loops as $name => $loop) {
464
+				$this->loops[$name] = clone $loop;
465
+			}
440 466
 
441
-			foreach ($this->items as $name => $item) $this->items[$name] = clone $item;
467
+			foreach ($this->items as $name => $item) {
468
+				$this->items[$name] = clone $item;
469
+			}
442 470
 		}
443 471
 
444 472
 		/**
Please login to merge, or discard this patch.