Passed
Push — master ( 8dd9cb...18e8f6 )
by Mihail
02:46
created
src/Application.php 2 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 					if (!is_dir(dirname($file))) mkdir(dirname($file), $this->chmod, true);
92 92
 					touch($path . DIRECTORY_SEPARATOR . $item);
93 93
 				} else if ($section == 'links') {
94
-					$link = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[0]);
95
-					$target = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[1]);
94
+					$link = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[ 0 ]);
95
+					$target = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[ 1 ]);
96 96
 					if (!is_dir(dirname($link))) mkdir(dirname($link), $this->chmod, true);
97 97
 					symlink($target, $link);
98 98
 				}
@@ -108,21 +108,21 @@  discard block
 block discarded – undo
108 108
 		$directory = new \RecursiveDirectoryIterator(realpath($path), \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS);
109 109
 		$iterator = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::SELF_FIRST);
110 110
 
111
-		$items = [];
111
+		$items = [ ];
112 112
 		foreach ($iterator as $item) {
113
-			$items[] = $item;
113
+			$items[ ] = $item;
114 114
 		}
115 115
 
116
-		if (empty($items)) return [];
116
+		if (empty($items)) return [ ];
117 117
 
118
-		$structure = [];
118
+		$structure = [ ];
119 119
 		foreach ($items as $item) {
120 120
 			if (is_link($item)) {
121
-				$structure['links'][] = str_ireplace(realpath($path) . DIRECTORY_SEPARATOR, '', $item) . ':' . str_ireplace(realpath($path) . DIRECTORY_SEPARATOR, '', readlink($item));
121
+				$structure[ 'links' ][ ] = str_ireplace(realpath($path) . DIRECTORY_SEPARATOR, '', $item) . ':' . str_ireplace(realpath($path) . DIRECTORY_SEPARATOR, '', readlink($item));
122 122
 			} else if (is_file($item)) {
123
-				$structure['files'][] = str_ireplace(realpath($path) . DIRECTORY_SEPARATOR, '', $item);
123
+				$structure[ 'files' ][ ] = str_ireplace(realpath($path) . DIRECTORY_SEPARATOR, '', $item);
124 124
 			} else if (is_dir($item)) {
125
-				$structure['dirs'][] = str_ireplace(realpath($path) . DIRECTORY_SEPARATOR, '', $item);
125
+				$structure[ 'dirs' ][ ] = str_ireplace(realpath($path) . DIRECTORY_SEPARATOR, '', $item);
126 126
 			}
127 127
 		}
128 128
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	public function sortStructure(array $structure) {
133 133
 		ksort($structure);
134 134
 
135
-		$structure = array_map(function ($item) {
135
+		$structure = array_map(function($item) {
136 136
 			sort($item);
137 137
 			return $item;
138 138
 		}, $structure);
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
 	}
142 142
 
143 143
 	public function diffStructure(array $structureThin, array $structureFat) {
144
-		if (empty($structureThin)) return [];
145
-		if (empty($structureFat)) return [];
144
+		if (empty($structureThin)) return [ ];
145
+		if (empty($structureFat)) return [ ];
146 146
 
147
-		$structureDiff = [];
147
+		$structureDiff = [ ];
148 148
 
149 149
 		foreach ($structureFat as $section => $items) {
150
-			if (empty($structureThin[$section])) continue;
151
-			$diff = array_diff($items, $structureThin[$section]);
150
+			if (empty($structureThin[ $section ])) continue;
151
+			$diff = array_diff($items, $structureThin[ $section ]);
152 152
 			if (empty($diff)) continue;
153
-			$structureDiff[$section] = $diff;
153
+			$structureDiff[ $section ] = $diff;
154 154
 		}
155 155
 
156 156
 		return $structureDiff;
@@ -159,20 +159,20 @@  discard block
 block discarded – undo
159 159
 	public function toRealpaths($path, array $structure) {
160 160
 		if (empty($path)) throw new \InvalidArgumentException('empty path');
161 161
 
162
-		if (empty($structure)) return [];
162
+		if (empty($structure)) return [ ];
163 163
 
164
-		$realpaths = [];
164
+		$realpaths = [ ];
165 165
 
166 166
 		foreach ($structure as $section => $items) {
167 167
 			if (empty($items)) continue;
168 168
 			foreach ($items as $item) {
169 169
 				if (empty($item)) continue;
170 170
 				if ($section == 'links') {
171
-					$realpaths[] = realpath($path) . DIRECTORY_SEPARATOR . explode(':', $item)[0];
171
+					$realpaths[ ] = realpath($path) . DIRECTORY_SEPARATOR . explode(':', $item)[ 0 ];
172 172
 				} else if ($section == 'files') {
173
-					$realpaths[] = realpath($path) . DIRECTORY_SEPARATOR . $item;
173
+					$realpaths[ ] = realpath($path) . DIRECTORY_SEPARATOR . $item;
174 174
 				} else if ($section == 'dirs') {
175
-					$realpaths[] = realpath($path) . DIRECTORY_SEPARATOR . $item;
175
+					$realpaths[ ] = realpath($path) . DIRECTORY_SEPARATOR . $item;
176 176
 				}
177 177
 			}
178 178
 		}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 		}
200 200
 
201 201
 		$path = $this->absolutePath($path, getcwd());
202
-		$messages = [];
202
+		$messages = [ ];
203 203
 
204 204
 		foreach ($this->structure as $section => $items) {
205 205
 			if (empty($items)) continue;
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
 				if (empty($item)) continue;
208 208
 				if ($section == 'dirs') {
209 209
 					$dir = $path . DIRECTORY_SEPARATOR . $item;
210
-					if (!is_dir($dir)) $messages[] = 'directory "' . $dir . '" not found';
210
+					if (!is_dir($dir)) $messages[ ] = 'directory "' . $dir . '" not found';
211 211
 				} else if ($section == 'files') {
212 212
 					$file = $path . DIRECTORY_SEPARATOR . $item;
213
-					if (!is_file($file)) $messages[] = 'file "' . $file . '" not found';
213
+					if (!is_file($file)) $messages[ ] = 'file "' . $file . '" not found';
214 214
 				} else if ($section == 'links') {
215
-					$link = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[0]);
216
-					if (!is_link($link)) $messages[] = 'link "' . realpath($link) . '" not found';
215
+					$link = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[ 0 ]);
216
+					if (!is_link($link)) $messages[ ] = 'link "' . realpath($link) . '" not found';
217 217
 				}
218 218
 			}
219 219
 		}
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
 		}
247 247
 
248 248
 		$path = $this->absolutePath($path, getcwd());
249
-		$messages = [];
249
+		$messages = [ ];
250 250
 
251 251
 		if (!is_dir($path)) {
252 252
 			if (mkdir($path, $this->chmod, true)) {
253
-				$messages[] = 'directory "' . realpath($path) . '" created';
253
+				$messages[ ] = 'directory "' . realpath($path) . '" created';
254 254
 			} else {
255 255
 				$payload->setType(Payload::STRUCTURE_INIT_FAIL);
256 256
 				$payload->setMessage('directory "' . $path . '" does not created');
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 				if ($section == 'dirs') {
267 267
 					$dir = $path . DIRECTORY_SEPARATOR . $item;
268 268
 					if (mkdir($dir, $this->chmod, true)) {
269
-						$messages[] = 'directory "' . $dir . '" created';
269
+						$messages[ ] = 'directory "' . $dir . '" created';
270 270
 					} else {
271 271
 						$payload->setType(Payload::STRUCTURE_INIT_FAIL);
272 272
 						$payload->setMessage('directory "' . $dir . '" does not created');
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 				} else if ($section == 'files') {
277 277
 					$file = $path . DIRECTORY_SEPARATOR . $item;
278 278
 					if (touch($file)) {
279
-						$messages[] = 'file "' . $file . '" created';
279
+						$messages[ ] = 'file "' . $file . '" created';
280 280
 					} else {
281 281
 						$payload->setType(Payload::STRUCTURE_INIT_FAIL);
282 282
 						$payload->setMessage('file"' . $file . '" does not created');
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
 						return $payload;
285 285
 					}
286 286
 				} else if ($section == 'links') {
287
-					$target = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[1]);
288
-					$link = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[0]);
287
+					$target = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[ 1 ]);
288
+					$link = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[ 0 ]);
289 289
 					if (symlink($target, $link)) {
290
-						$messages[] = 'link "' . $link . '" created';
290
+						$messages[ ] = 'link "' . $link . '" created';
291 291
 					} else {
292 292
 						$payload->setType(Payload::STRUCTURE_INIT_FAIL);
293 293
 						$payload->setMessage('link ' . $link . '" does not created');
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 		}
331 331
 
332 332
 		$payload->setType(Payload::STRUCTURE_CLEAN_SUCCESS);
333
-		$payload->setMessage(array_merge(['cleaned items:'], $realpathsDiff));
333
+		$payload->setMessage(array_merge([ 'cleaned items:' ], $realpathsDiff));
334 334
 		$payload->setCode(0);
335 335
 		return $payload;
336 336
 	}
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 			return $payload;
478 478
 		}
479 479
 
480
-		$dirs = array_map(function ($path) {
480
+		$dirs = array_map(function($path) {
481 481
 			return basename($path);
482 482
 		}, $dirs);
483 483
 
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 			return $payload;
513 513
 		}
514 514
 
515
-		$dirs = array_map(function ($path) {
515
+		$dirs = array_map(function($path) {
516 516
 			return basename($path);
517 517
 		}, $dirs);
518 518
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 		if (empty($path)) throw new \InvalidArgumentException('empty path');
661 661
 		if (empty($cwd)) throw new \InvalidArgumentException('empty cwd');
662 662
 
663
-		if ($path[0] == '/') return $path;
663
+		if ($path[ 0 ] == '/') return $path;
664 664
 
665 665
 		return $cwd . DIRECTORY_SEPARATOR . $path;
666 666
 	}
Please login to merge, or discard this 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.