| Conditions | 6 |
| Paths | 24 |
| Total Lines | 24 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 22 |
| CRAP Score | 6 |
| Changes | 3 | ||
| Bugs | 1 | Features | 2 |
| 1 | <?php |
||
| 11 | 2 | public function executeCommand($scriptPath, array $env) |
|
| 12 | { |
||
| 13 | 2 | $oldCwd = NULL; |
|
| 14 | 2 | if (is_array($scriptPath)) { |
|
| 15 | 1 | if (isset($scriptPath['cwd'])) { |
|
| 16 | 1 | $cwd = $scriptPath['cwd']; |
|
| 17 | 1 | unset($scriptPath['cwd']); |
|
| 18 | 1 | $oldCwd = getcwd(); |
|
| 19 | 1 | chdir($cwd); |
|
| 20 | 1 | } |
|
| 21 | 1 | $commands = $scriptPath; |
|
| 22 | 1 | } else { |
|
| 23 | 1 | $commands = [$scriptPath]; |
|
| 24 | } |
||
| 25 | 2 | foreach ($env as $key => $value) { |
|
| 26 | 2 | putenv($key . '=' . $value); |
|
| 27 | 2 | } |
|
| 28 | 2 | foreach ($commands as $command) { |
|
| 29 | 2 | shell_exec($command); |
|
| 30 | 2 | } |
|
| 31 | 2 | if ($oldCwd !== NULL) { |
|
| 32 | 1 | chdir($oldCwd); |
|
| 33 | 1 | } |
|
| 34 | 2 | } |
|
| 35 | |||
| 37 |