Passed
Push — master ( 8dd9cb...18e8f6 )
by Mihail
02:46
created
src/Application.php 1 patch
Braces   +93 added lines, -31 removed lines patch added patch discarded remove patch
@@ -75,25 +75,37 @@  discard block
 block discarded – undo
75 75
 	}
76 76
 
77 77
 	public function makeStructure($path, array $structure) {
78
-		if (empty($path)) throw new \InvalidArgumentException('empty path');
78
+		if (empty($path)) {
79
+			throw new \InvalidArgumentException('empty path');
80
+		}
79 81
 
80
-		if (empty($structure)) true;
82
+		if (empty($structure)) {
83
+			true;
84
+		}
81 85
 
82 86
 		foreach ($structure as $section => $items) {
83
-			if (empty($items)) continue;
87
+			if (empty($items)) {
88
+				continue;
89
+			}
84 90
 			foreach ($items as $item) {
85
-				if (empty($item)) continue;
91
+				if (empty($item)) {
92
+					continue;
93
+				}
86 94
 				if ($section == 'dirs') {
87 95
 					$dir = $path . DIRECTORY_SEPARATOR . $item;
88 96
 					mkdir($dir, $this->chmod, true);
89 97
 				} else if ($section == 'files') {
90 98
 					$file = $path . DIRECTORY_SEPARATOR . $item;
91
-					if (!is_dir(dirname($file))) mkdir(dirname($file), $this->chmod, true);
99
+					if (!is_dir(dirname($file))) {
100
+						mkdir(dirname($file), $this->chmod, true);
101
+					}
92 102
 					touch($path . DIRECTORY_SEPARATOR . $item);
93 103
 				} else if ($section == 'links') {
94 104
 					$link = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[0]);
95 105
 					$target = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[1]);
96
-					if (!is_dir(dirname($link))) mkdir(dirname($link), $this->chmod, true);
106
+					if (!is_dir(dirname($link))) {
107
+						mkdir(dirname($link), $this->chmod, true);
108
+					}
97 109
 					symlink($target, $link);
98 110
 				}
99 111
 			}
@@ -103,7 +115,9 @@  discard block
 block discarded – undo
103 115
 	}
104 116
 
105 117
 	public function scanStructure($path) {
106
-		if (empty($path)) throw new \InvalidArgumentException('empty path');
118
+		if (empty($path)) {
119
+			throw new \InvalidArgumentException('empty path');
120
+		}
107 121
 
108 122
 		$directory = new \RecursiveDirectoryIterator(realpath($path), \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS);
109 123
 		$iterator = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::SELF_FIRST);
@@ -113,7 +127,9 @@  discard block
 block discarded – undo
113 127
 			$items[] = $item;
114 128
 		}
115 129
 
116
-		if (empty($items)) return [];
130
+		if (empty($items)) {
131
+			return [];
132
+		}
117 133
 
118 134
 		$structure = [];
119 135
 		foreach ($items as $item) {
@@ -141,15 +157,23 @@  discard block
 block discarded – undo
141 157
 	}
142 158
 
143 159
 	public function diffStructure(array $structureThin, array $structureFat) {
144
-		if (empty($structureThin)) return [];
145
-		if (empty($structureFat)) return [];
160
+		if (empty($structureThin)) {
161
+			return [];
162
+		}
163
+		if (empty($structureFat)) {
164
+			return [];
165
+		}
146 166
 
147 167
 		$structureDiff = [];
148 168
 
149 169
 		foreach ($structureFat as $section => $items) {
150
-			if (empty($structureThin[$section])) continue;
170
+			if (empty($structureThin[$section])) {
171
+				continue;
172
+			}
151 173
 			$diff = array_diff($items, $structureThin[$section]);
152
-			if (empty($diff)) continue;
174
+			if (empty($diff)) {
175
+				continue;
176
+			}
153 177
 			$structureDiff[$section] = $diff;
154 178
 		}
155 179
 
@@ -157,16 +181,24 @@  discard block
 block discarded – undo
157 181
 	}
158 182
 
159 183
 	public function toRealpaths($path, array $structure) {
160
-		if (empty($path)) throw new \InvalidArgumentException('empty path');
184
+		if (empty($path)) {
185
+			throw new \InvalidArgumentException('empty path');
186
+		}
161 187
 
162
-		if (empty($structure)) return [];
188
+		if (empty($structure)) {
189
+			return [];
190
+		}
163 191
 
164 192
 		$realpaths = [];
165 193
 
166 194
 		foreach ($structure as $section => $items) {
167
-			if (empty($items)) continue;
195
+			if (empty($items)) {
196
+				continue;
197
+			}
168 198
 			foreach ($items as $item) {
169
-				if (empty($item)) continue;
199
+				if (empty($item)) {
200
+					continue;
201
+				}
170 202
 				if ($section == 'links') {
171 203
 					$realpaths[] = realpath($path) . DIRECTORY_SEPARATOR . explode(':', $item)[0];
172 204
 				} else if ($section == 'files') {
@@ -202,18 +234,28 @@  discard block
 block discarded – undo
202 234
 		$messages = [];
203 235
 
204 236
 		foreach ($this->structure as $section => $items) {
205
-			if (empty($items)) continue;
237
+			if (empty($items)) {
238
+				continue;
239
+			}
206 240
 			foreach ($items as $item) {
207
-				if (empty($item)) continue;
241
+				if (empty($item)) {
242
+					continue;
243
+				}
208 244
 				if ($section == 'dirs') {
209 245
 					$dir = $path . DIRECTORY_SEPARATOR . $item;
210
-					if (!is_dir($dir)) $messages[] = 'directory "' . $dir . '" not found';
246
+					if (!is_dir($dir)) {
247
+						$messages[] = 'directory "' . $dir . '" not found';
248
+					}
211 249
 				} else if ($section == 'files') {
212 250
 					$file = $path . DIRECTORY_SEPARATOR . $item;
213
-					if (!is_file($file)) $messages[] = 'file "' . $file . '" not found';
251
+					if (!is_file($file)) {
252
+						$messages[] = 'file "' . $file . '" not found';
253
+					}
214 254
 				} else if ($section == 'links') {
215 255
 					$link = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[0]);
216
-					if (!is_link($link)) $messages[] = 'link "' . realpath($link) . '" not found';
256
+					if (!is_link($link)) {
257
+						$messages[] = 'link "' . realpath($link) . '" not found';
258
+					}
217 259
 				}
218 260
 			}
219 261
 		}
@@ -260,9 +302,13 @@  discard block
 block discarded – undo
260 302
 		}
261 303
 
262 304
 		foreach ($this->structure as $section => $items) {
263
-			if (empty($items)) continue;
305
+			if (empty($items)) {
306
+				continue;
307
+			}
264 308
 			foreach ($items as $item) {
265
-				if (empty($item)) continue;
309
+				if (empty($item)) {
310
+					continue;
311
+				}
266 312
 				if ($section == 'dirs') {
267 313
 					$dir = $path . DIRECTORY_SEPARATOR . $item;
268 314
 					if (mkdir($dir, $this->chmod, true)) {
@@ -323,10 +369,18 @@  discard block
 block discarded – undo
323 369
 		$realpathsDiff = array_diff($realpathsDirty, $realpathsClean);
324 370
 
325 371
 		foreach ($realpathsDiff as $item) {
326
-			if (empty($item)) continue;
327
-			if (is_link($item)) unlink($item);
328
-			if (is_file($item)) unlink($item);
329
-			if (is_dir($item)) rmdir($item);
372
+			if (empty($item)) {
373
+				continue;
374
+			}
375
+			if (is_link($item)) {
376
+				unlink($item);
377
+			}
378
+			if (is_file($item)) {
379
+				unlink($item);
380
+			}
381
+			if (is_dir($item)) {
382
+				rmdir($item);
383
+			}
330 384
 		}
331 385
 
332 386
 		$payload->setType(Payload::STRUCTURE_CLEAN_SUCCESS);
@@ -645,7 +699,9 @@  discard block
 block discarded – undo
645 699
 		}
646 700
 
647 701
 		foreach (array_reverse($releases) as $idx => $release) {
648
-			if ($idx <= ($quantity - 1)) continue;
702
+			if ($idx <= ($quantity - 1)) {
703
+				continue;
704
+			}
649 705
 			$proccess = new Process('rm -r ' . $release);
650 706
 			$proccess->run();
651 707
 		}
@@ -657,10 +713,16 @@  discard block
 block discarded – undo
657 713
 	}
658 714
 
659 715
 	public function absolutePath($path, $cwd) {
660
-		if (empty($path)) throw new \InvalidArgumentException('empty path');
661
-		if (empty($cwd)) throw new \InvalidArgumentException('empty cwd');
716
+		if (empty($path)) {
717
+			throw new \InvalidArgumentException('empty path');
718
+		}
719
+		if (empty($cwd)) {
720
+			throw new \InvalidArgumentException('empty cwd');
721
+		}
662 722
 
663
-		if ($path[0] == '/') return $path;
723
+		if ($path[0] == '/') {
724
+			return $path;
725
+		}
664 726
 
665 727
 		return $cwd . DIRECTORY_SEPARATOR . $path;
666 728
 	}
Please login to merge, or discard this patch.