@@ -10,8 +10,12 @@ |
||
| 10 | 10 | }; |
| 11 | 11 | |
| 12 | 12 | // clean up |
| 13 | -if (file_exists($pharFile)) unlink($pharFile); |
|
| 14 | -if (file_exists($pharFile . '.gz')) unlink($pharFile . '.gz'); |
|
| 13 | +if (file_exists($pharFile)) { |
|
| 14 | + unlink($pharFile); |
|
| 15 | +} |
|
| 16 | +if (file_exists($pharFile . '.gz')) { |
|
| 17 | + unlink($pharFile . '.gz'); |
|
| 18 | +} |
|
| 15 | 19 | |
| 16 | 20 | try { |
| 17 | 21 | $phar = new Phar($pharFile); |
@@ -78,7 +78,9 @@ |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public function setCode($code) { |
| 81 | - if (!\is_numeric($code)) throw new \InvalidArgumentException('expected numeric'); |
|
| 81 | + if (!\is_numeric($code)) { |
|
| 82 | + throw new \InvalidArgumentException('expected numeric'); |
|
| 83 | + } |
|
| 82 | 84 | $this->code = $code; |
| 83 | 85 | return $this; |
| 84 | 86 | } |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $path = $this->absolutePath($path, getcwd()); |
| 89 | - $messages = []; |
|
| 89 | + $messages = [ ]; |
|
| 90 | 90 | |
| 91 | 91 | if (!is_dir($path)) { |
| 92 | 92 | if (mkdir($path, 0777, true)) { |
| 93 | - $messages[] = 'directory "' . realpath($path) . '" created'; |
|
| 93 | + $messages[ ] = 'directory "' . realpath($path) . '" created'; |
|
| 94 | 94 | } else { |
| 95 | 95 | $payload->setType(Payload::STRUCTURE_REPAIR_FAIL); |
| 96 | 96 | $payload->setMessage('directory "' . $path . '" does not created'); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $releasesDir = $path . DIRECTORY_SEPARATOR . 'releases'; |
| 103 | 103 | if (!is_dir($releasesDir)) { |
| 104 | 104 | if (mkdir($releasesDir, 0777, true)) { |
| 105 | - $messages[] = 'directory "' . realpath($releasesDir) . '" created'; |
|
| 105 | + $messages[ ] = 'directory "' . realpath($releasesDir) . '" created'; |
|
| 106 | 106 | } else { |
| 107 | 107 | $payload->setType(Payload::STRUCTURE_REPAIR_FAIL); |
| 108 | 108 | $payload->setMessage('directory "' . $releasesDir . '" does not created'); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $sharedDir = $path . DIRECTORY_SEPARATOR . 'shared'; |
| 115 | 115 | if (!is_dir($sharedDir)) { |
| 116 | 116 | if (mkdir($sharedDir, 0777, true)) { |
| 117 | - $messages[] = 'directory "' . realpath($sharedDir) . '" created'; |
|
| 117 | + $messages[ ] = 'directory "' . realpath($sharedDir) . '" created'; |
|
| 118 | 118 | } else { |
| 119 | 119 | $payload->setType(Payload::STRUCTURE_REPAIR_FAIL); |
| 120 | 120 | $payload->setMessage('directory "' . $sharedDir . '" does not created'); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $logFile = $path . DIRECTORY_SEPARATOR . 'deploid.log'; |
| 127 | 127 | if (!is_file($logFile)) { |
| 128 | 128 | if (touch($logFile)) { |
| 129 | - $messages[] = 'file "' . realpath($logFile) . '" created'; |
|
| 129 | + $messages[ ] = 'file "' . realpath($logFile) . '" created'; |
|
| 130 | 130 | } else { |
| 131 | 131 | $payload->setType(Payload::STRUCTURE_REPAIR_FAIL); |
| 132 | 132 | $payload->setMessage('file"' . $logFile . '" does not created'); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | 'deploid.log', |
| 167 | 167 | ]; |
| 168 | 168 | |
| 169 | - $paths = array_filter($paths, function ($path) use ($needed) { |
|
| 169 | + $paths = array_filter($paths, function($path) use ($needed) { |
|
| 170 | 170 | return !in_array(basename($path), $needed); |
| 171 | 171 | }); |
| 172 | 172 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | $payload->setType(Payload::STRUCTURE_CLEAN_SUCCESS); |
| 179 | - $payload->setMessage(array_merge(['cleaned items:'], $paths)); |
|
| 179 | + $payload->setMessage(array_merge([ 'cleaned items:' ], $paths)); |
|
| 180 | 180 | $payload->setCode(0); |
| 181 | 181 | return $payload; |
| 182 | 182 | } |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | return $payload; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - $dirs = array_map(function ($path) { |
|
| 326 | + $dirs = array_map(function($path) { |
|
| 327 | 327 | return basename($path); |
| 328 | 328 | }, $dirs); |
| 329 | 329 | |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | return $payload; |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - $dirs = array_map(function ($path) { |
|
| 361 | + $dirs = array_map(function($path) { |
|
| 362 | 362 | return basename($path); |
| 363 | 363 | }, $dirs); |
| 364 | 364 | |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | public function absolutePath($path, $cwd) { |
| 506 | - if ($path[0] == '/') return $path; |
|
| 506 | + if ($path[ 0 ] == '/') return $path; |
|
| 507 | 507 | return $cwd . DIRECTORY_SEPARATOR . $path; |
| 508 | 508 | } |
| 509 | 509 | |
@@ -171,8 +171,12 @@ discard block |
||
| 171 | 171 | }); |
| 172 | 172 | |
| 173 | 173 | foreach ($paths as $path) { |
| 174 | - if (is_dir($path)) rmdir($path); |
|
| 175 | - if (is_file($path)) unlink($path); |
|
| 174 | + if (is_dir($path)) { |
|
| 175 | + rmdir($path); |
|
| 176 | + } |
|
| 177 | + if (is_file($path)) { |
|
| 178 | + unlink($path); |
|
| 179 | + } |
|
| 176 | 180 | } |
| 177 | 181 | |
| 178 | 182 | $payload->setType(Payload::STRUCTURE_CLEAN_SUCCESS); |
@@ -491,7 +495,9 @@ discard block |
||
| 491 | 495 | } |
| 492 | 496 | |
| 493 | 497 | foreach (array_reverse($releases) as $idx => $release) { |
| 494 | - if ($idx <= ($quantity - 1)) continue; |
|
| 498 | + if ($idx <= ($quantity - 1)) { |
|
| 499 | + continue; |
|
| 500 | + } |
|
| 495 | 501 | $proccess = new Process('rm -r ' . $release); |
| 496 | 502 | $proccess->run(); |
| 497 | 503 | } |
@@ -503,7 +509,9 @@ discard block |
||
| 503 | 509 | } |
| 504 | 510 | |
| 505 | 511 | public function absolutePath($path, $cwd) { |
| 506 | - if ($path[0] == '/') return $path; |
|
| 512 | + if ($path[0] == '/') { |
|
| 513 | + return $path; |
|
| 514 | + } |
|
| 507 | 515 | return $cwd . DIRECTORY_SEPARATOR . $path; |
| 508 | 516 | } |
| 509 | 517 | |