@@ -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 | } |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | $path = $this->absolutePath($path, getcwd()); |
| 122 | - $messages = []; |
|
| 122 | + $messages = [ ]; |
|
| 123 | 123 | |
| 124 | 124 | if (!is_dir($path)) { |
| 125 | 125 | if (mkdir($path, 0777, true)) { |
| 126 | - $messages[] = 'directory "' . realpath($path) . '" created'; |
|
| 126 | + $messages[ ] = 'directory "' . realpath($path) . '" created'; |
|
| 127 | 127 | } else { |
| 128 | 128 | $payload->setType(Payload::STRUCTURE_INIT_FAIL); |
| 129 | 129 | $payload->setMessage('directory "' . $path . '" does not created'); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | $releasesDir = $path . DIRECTORY_SEPARATOR . 'releases'; |
| 136 | 136 | if (!is_dir($releasesDir)) { |
| 137 | 137 | if (mkdir($releasesDir, 0777, true)) { |
| 138 | - $messages[] = 'directory "' . realpath($releasesDir) . '" created'; |
|
| 138 | + $messages[ ] = 'directory "' . realpath($releasesDir) . '" created'; |
|
| 139 | 139 | } else { |
| 140 | 140 | $payload->setType(Payload::STRUCTURE_INIT_FAIL); |
| 141 | 141 | $payload->setMessage('directory "' . $releasesDir . '" does not created'); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $sharedDir = $path . DIRECTORY_SEPARATOR . 'shared'; |
| 148 | 148 | if (!is_dir($sharedDir)) { |
| 149 | 149 | if (mkdir($sharedDir, 0777, true)) { |
| 150 | - $messages[] = 'directory "' . realpath($sharedDir) . '" created'; |
|
| 150 | + $messages[ ] = 'directory "' . realpath($sharedDir) . '" created'; |
|
| 151 | 151 | } else { |
| 152 | 152 | $payload->setType(Payload::STRUCTURE_INIT_FAIL); |
| 153 | 153 | $payload->setMessage('directory "' . $sharedDir . '" does not created'); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $logFile = $path . DIRECTORY_SEPARATOR . 'deploid.log'; |
| 160 | 160 | if (!is_file($logFile)) { |
| 161 | 161 | if (touch($logFile)) { |
| 162 | - $messages[] = 'file "' . realpath($logFile) . '" created'; |
|
| 162 | + $messages[ ] = 'file "' . realpath($logFile) . '" created'; |
|
| 163 | 163 | } else { |
| 164 | 164 | $payload->setType(Payload::STRUCTURE_INIT_FAIL); |
| 165 | 165 | $payload->setMessage('file"' . $logFile . '" does not created'); |
@@ -192,8 +192,8 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | $paths = glob(realpath($path) . DIRECTORY_SEPARATOR . '*'); |
| 194 | 194 | |
| 195 | - $paths = array_filter($paths, function ($path) { |
|
| 196 | - return !in_array(basename($path), $this->structure['dirs'] + $this->structure['links'] + $this->structure['files']); |
|
| 195 | + $paths = array_filter($paths, function($path) { |
|
| 196 | + return !in_array(basename($path), $this->structure[ 'dirs' ] + $this->structure[ 'links' ] + $this->structure[ 'files' ]); |
|
| 197 | 197 | }); |
| 198 | 198 | |
| 199 | 199 | foreach ($paths as $pathname) { |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | $payload->setType(Payload::STRUCTURE_CLEAN_SUCCESS); |
| 208 | - $payload->setMessage(array_merge(['cleaned items:'], $paths)); |
|
| 208 | + $payload->setMessage(array_merge([ 'cleaned items:' ], $paths)); |
|
| 209 | 209 | $payload->setCode(0); |
| 210 | 210 | return $payload; |
| 211 | 211 | } |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | return $payload; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - $dirs = array_map(function ($path) { |
|
| 355 | + $dirs = array_map(function($path) { |
|
| 356 | 356 | return basename($path); |
| 357 | 357 | }, $dirs); |
| 358 | 358 | |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | return $payload; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - $dirs = array_map(function ($path) { |
|
| 390 | + $dirs = array_map(function($path) { |
|
| 391 | 391 | return basename($path); |
| 392 | 392 | }, $dirs); |
| 393 | 393 | |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | public function absolutePath($path, $cwd) { |
| 535 | - if ($path[0] == '/') return $path; |
|
| 535 | + if ($path[ 0 ] == '/') return $path; |
|
| 536 | 536 | return $cwd . DIRECTORY_SEPARATOR . $path; |
| 537 | 537 | } |
| 538 | 538 | |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | foreach ($sections as $section => $item) { |
| 542 | 542 | if ($section == 'dirs') mkdir($path . DIRECTORY_SEPARATOR . $item, 0777, true); |
| 543 | 543 | if ($section == 'files') touch($path . DIRECTORY_SEPARATOR . $item); |
| 544 | - if ($section == 'links') link($path . DIRECTORY_SEPARATOR . explode(':', $item)[0], $path . DIRECTORY_SEPARATOR . explode(':', $item)[1]); |
|
| 544 | + if ($section == 'links') link($path . DIRECTORY_SEPARATOR . explode(':', $item)[ 0 ], $path . DIRECTORY_SEPARATOR . explode(':', $item)[ 1 ]); |
|
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | 547 | } |
@@ -520,7 +520,9 @@ discard block |
||
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | foreach (array_reverse($releases) as $idx => $release) { |
| 523 | - if ($idx <= ($quantity - 1)) continue; |
|
| 523 | + if ($idx <= ($quantity - 1)) { |
|
| 524 | + continue; |
|
| 525 | + } |
|
| 524 | 526 | $proccess = new Process('rm -r ' . $release); |
| 525 | 527 | $proccess->run(); |
| 526 | 528 | } |
@@ -532,16 +534,24 @@ discard block |
||
| 532 | 534 | } |
| 533 | 535 | |
| 534 | 536 | public function absolutePath($path, $cwd) { |
| 535 | - if ($path[0] == '/') return $path; |
|
| 537 | + if ($path[0] == '/') { |
|
| 538 | + return $path; |
|
| 539 | + } |
|
| 536 | 540 | return $cwd . DIRECTORY_SEPARATOR . $path; |
| 537 | 541 | } |
| 538 | 542 | |
| 539 | 543 | public function makeStructure($path, array $structure) { |
| 540 | 544 | foreach ($structure as $sections) { |
| 541 | 545 | foreach ($sections as $section => $item) { |
| 542 | - if ($section == 'dirs') mkdir($path . DIRECTORY_SEPARATOR . $item, 0777, true); |
|
| 543 | - if ($section == 'files') touch($path . DIRECTORY_SEPARATOR . $item); |
|
| 544 | - if ($section == 'links') link($path . DIRECTORY_SEPARATOR . explode(':', $item)[0], $path . DIRECTORY_SEPARATOR . explode(':', $item)[1]); |
|
| 546 | + if ($section == 'dirs') { |
|
| 547 | + mkdir($path . DIRECTORY_SEPARATOR . $item, 0777, true); |
|
| 548 | + } |
|
| 549 | + if ($section == 'files') { |
|
| 550 | + touch($path . DIRECTORY_SEPARATOR . $item); |
|
| 551 | + } |
|
| 552 | + if ($section == 'links') { |
|
| 553 | + link($path . DIRECTORY_SEPARATOR . explode(':', $item)[0], $path . DIRECTORY_SEPARATOR . explode(':', $item)[1]); |
|
| 554 | + } |
|
| 545 | 555 | } |
| 546 | 556 | } |
| 547 | 557 | } |