@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | if (empty($item)) continue; |
| 85 | 85 | if ($section == 'dirs') mkdir($path . DIRECTORY_SEPARATOR . $item, $this->chmod, true); |
| 86 | 86 | if ($section == 'files') touch($path . DIRECTORY_SEPARATOR . $item); |
| 87 | - if ($section == 'links') symlink($path . DIRECTORY_SEPARATOR . (explode(':', $item)[1]), $path . DIRECTORY_SEPARATOR . (explode(':', $item)[0])); |
|
| 87 | + if ($section == 'links') symlink($path . DIRECTORY_SEPARATOR . (explode(':', $item)[ 1 ]), $path . DIRECTORY_SEPARATOR . (explode(':', $item)[ 0 ])); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
@@ -147,11 +147,11 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $path = $this->absolutePath($path, getcwd()); |
| 150 | - $messages = []; |
|
| 150 | + $messages = [ ]; |
|
| 151 | 151 | |
| 152 | 152 | if (!is_dir($path)) { |
| 153 | 153 | if (mkdir($path, $this->chmod, true)) { |
| 154 | - $messages[] = 'directory "' . realpath($path) . '" created'; |
|
| 154 | + $messages[ ] = 'directory "' . realpath($path) . '" created'; |
|
| 155 | 155 | } else { |
| 156 | 156 | $payload->setType(Payload::STRUCTURE_INIT_FAIL); |
| 157 | 157 | $payload->setMessage('directory "' . $path . '" does not created'); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | if ($section == 'dirs') { |
| 168 | 168 | $dir = $path . DIRECTORY_SEPARATOR . $item; |
| 169 | 169 | if (mkdir($dir, $this->chmod, true)) { |
| 170 | - $messages[] = 'directory "' . realpath($dir) . '" created'; |
|
| 170 | + $messages[ ] = 'directory "' . realpath($dir) . '" created'; |
|
| 171 | 171 | } else { |
| 172 | 172 | $payload->setType(Payload::STRUCTURE_INIT_FAIL); |
| 173 | 173 | $payload->setMessage('directory "' . $dir . '" does not created'); |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | if ($section == 'files') { |
| 179 | 179 | $file = $path . DIRECTORY_SEPARATOR . $item; |
| 180 | 180 | if (touch($file)) { |
| 181 | - $messages[] = 'file "' . realpath($file) . '" created'; |
|
| 181 | + $messages[ ] = 'file "' . realpath($file) . '" created'; |
|
| 182 | 182 | } else { |
| 183 | 183 | $payload->setType(Payload::STRUCTURE_INIT_FAIL); |
| 184 | 184 | $payload->setMessage('file"' . $file . '" does not created'); |
@@ -187,10 +187,10 @@ discard block |
||
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | if ($section == 'links') { |
| 190 | - $target = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[1]); |
|
| 191 | - $link = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[0]); |
|
| 190 | + $target = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[ 1 ]); |
|
| 191 | + $link = $path . DIRECTORY_SEPARATOR . (explode(':', $item)[ 0 ]); |
|
| 192 | 192 | if (symlink($target, $link)) { |
| 193 | - $messages[] = 'link "' . realpath($link) . '" created'; |
|
| 193 | + $messages[ ] = 'link "' . realpath($link) . '" created'; |
|
| 194 | 194 | } else { |
| 195 | 195 | $payload->setType(Payload::STRUCTURE_INIT_FAIL); |
| 196 | 196 | $payload->setMessage('link ' . $link . '" does not created'); |
@@ -225,8 +225,8 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | $paths = glob(realpath($path) . DIRECTORY_SEPARATOR . '*'); |
| 227 | 227 | |
| 228 | - $paths = array_filter($paths, function ($path) { |
|
| 229 | - return !in_array(basename($path), $this->structure['dirs'] + $this->structure['links'] + $this->structure['files']); |
|
| 228 | + $paths = array_filter($paths, function($path) { |
|
| 229 | + return !in_array(basename($path), $this->structure[ 'dirs' ] + $this->structure[ 'links' ] + $this->structure[ 'files' ]); |
|
| 230 | 230 | }); |
| 231 | 231 | |
| 232 | 232 | foreach ($paths as $pathname) { |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $payload->setType(Payload::STRUCTURE_CLEAN_SUCCESS); |
| 243 | - $payload->setMessage(array_merge(['cleaned items:'], $paths)); |
|
| 243 | + $payload->setMessage(array_merge([ 'cleaned items:' ], $paths)); |
|
| 244 | 244 | $payload->setCode(0); |
| 245 | 245 | return $payload; |
| 246 | 246 | } |
@@ -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 | |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | return $payload; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - $dirs = array_map(function ($path) { |
|
| 425 | + $dirs = array_map(function($path) { |
|
| 426 | 426 | return basename($path); |
| 427 | 427 | }, $dirs); |
| 428 | 428 | |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | if (empty($path)) throw new \InvalidArgumentException('empty path'); |
| 571 | 571 | if (empty($cwd)) throw new \InvalidArgumentException('empty cwd'); |
| 572 | 572 | |
| 573 | - if ($path[0] == '/') return $path; |
|
| 573 | + if ($path[ 0 ] == '/') return $path; |
|
| 574 | 574 | |
| 575 | 575 | return $cwd . DIRECTORY_SEPARATOR . $path; |
| 576 | 576 | } |
@@ -75,16 +75,30 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | public function makeStructure($path, array $structure) { |
| 78 | - if (empty($path)) throw new \InvalidArgumentException('empty path'); |
|
| 79 | - if (empty($structure)) throw new \InvalidArgumentException('empty structure'); |
|
| 78 | + if (empty($path)) { |
|
| 79 | + throw new \InvalidArgumentException('empty path'); |
|
| 80 | + } |
|
| 81 | + if (empty($structure)) { |
|
| 82 | + throw new \InvalidArgumentException('empty structure'); |
|
| 83 | + } |
|
| 80 | 84 | |
| 81 | 85 | foreach ($structure as $section => $items) { |
| 82 | - if (empty($items)) continue; |
|
| 86 | + if (empty($items)) { |
|
| 87 | + continue; |
|
| 88 | + } |
|
| 83 | 89 | foreach ($items as $item) { |
| 84 | - if (empty($item)) continue; |
|
| 85 | - if ($section == 'dirs') mkdir($path . DIRECTORY_SEPARATOR . $item, $this->chmod, true); |
|
| 86 | - if ($section == 'files') touch($path . DIRECTORY_SEPARATOR . $item); |
|
| 87 | - if ($section == 'links') symlink($path . DIRECTORY_SEPARATOR . (explode(':', $item)[1]), $path . DIRECTORY_SEPARATOR . (explode(':', $item)[0])); |
|
| 90 | + if (empty($item)) { |
|
| 91 | + continue; |
|
| 92 | + } |
|
| 93 | + if ($section == 'dirs') { |
|
| 94 | + mkdir($path . DIRECTORY_SEPARATOR . $item, $this->chmod, true); |
|
| 95 | + } |
|
| 96 | + if ($section == 'files') { |
|
| 97 | + touch($path . DIRECTORY_SEPARATOR . $item); |
|
| 98 | + } |
|
| 99 | + if ($section == 'links') { |
|
| 100 | + symlink($path . DIRECTORY_SEPARATOR . (explode(':', $item)[1]), $path . DIRECTORY_SEPARATOR . (explode(':', $item)[0])); |
|
| 101 | + } |
|
| 88 | 102 | } |
| 89 | 103 | } |
| 90 | 104 | |
@@ -161,9 +175,13 @@ discard block |
||
| 161 | 175 | } |
| 162 | 176 | |
| 163 | 177 | foreach ($structure as $section => $items) { |
| 164 | - if (empty($items)) continue; |
|
| 178 | + if (empty($items)) { |
|
| 179 | + continue; |
|
| 180 | + } |
|
| 165 | 181 | foreach ($items as $item) { |
| 166 | - if (empty($item)) continue; |
|
| 182 | + if (empty($item)) { |
|
| 183 | + continue; |
|
| 184 | + } |
|
| 167 | 185 | if ($section == 'dirs') { |
| 168 | 186 | $dir = $path . DIRECTORY_SEPARATOR . $item; |
| 169 | 187 | if (mkdir($dir, $this->chmod, true)) { |
@@ -555,7 +573,9 @@ discard block |
||
| 555 | 573 | } |
| 556 | 574 | |
| 557 | 575 | foreach (array_reverse($releases) as $idx => $release) { |
| 558 | - if ($idx <= ($quantity - 1)) continue; |
|
| 576 | + if ($idx <= ($quantity - 1)) { |
|
| 577 | + continue; |
|
| 578 | + } |
|
| 559 | 579 | $proccess = new Process('rm -r ' . $release); |
| 560 | 580 | $proccess->run(); |
| 561 | 581 | } |
@@ -567,10 +587,16 @@ discard block |
||
| 567 | 587 | } |
| 568 | 588 | |
| 569 | 589 | public function absolutePath($path, $cwd) { |
| 570 | - if (empty($path)) throw new \InvalidArgumentException('empty path'); |
|
| 571 | - if (empty($cwd)) throw new \InvalidArgumentException('empty cwd'); |
|
| 590 | + if (empty($path)) { |
|
| 591 | + throw new \InvalidArgumentException('empty path'); |
|
| 592 | + } |
|
| 593 | + if (empty($cwd)) { |
|
| 594 | + throw new \InvalidArgumentException('empty cwd'); |
|
| 595 | + } |
|
| 572 | 596 | |
| 573 | - if ($path[0] == '/') return $path; |
|
| 597 | + if ($path[0] == '/') { |
|
| 598 | + return $path; |
|
| 599 | + } |
|
| 574 | 600 | |
| 575 | 601 | return $cwd . DIRECTORY_SEPARATOR . $path; |
| 576 | 602 | } |