| Conditions | 4 |
| Paths | 8 |
| Total Lines | 18 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4.4882 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | 1 | public function createRelative($directory, $target, $link) |
|
| 29 | { |
||
| 30 | 1 | if (!is_dir($directory)) { |
|
| 31 | $this->error("Directory '$directory' not found."); |
||
| 32 | } |
||
| 33 | 1 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
|
| 34 | $cmd = 'cd ' . escapeshellarg($directory) . ' && mklink ' . ' /D ' . escapeshellarg($link) . ' ' . escapeshellarg($target); |
||
| 35 | } else { |
||
| 36 | 1 | $cmd = 'cd ' . escapeshellarg($directory) . ' && ln -s ' . escapeshellarg($target) . ' ' . escapeshellarg($link); |
|
| 37 | } |
||
| 38 | 1 | $command = new Commands\Exec(); |
|
| 39 | 1 | $command->setCommand($cmd); |
|
| 40 | 1 | $result = $command->execute(); |
|
| 41 | 1 | if ($result->getResult() !== 0) { |
|
| 42 | $this->error("Cannot create symlink '$target' - '$link' in directory '$directory'."); |
||
| 43 | 1 | } |
|
| 44 | 1 | return $result; |
|
| 45 | 1 | } |
|
| 46 | |||
| 47 | } |