Passed
Push — master ( 15fbce...c7ecbb )
by Jan
03:02
created

Executor   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 6
c 3
b 1
f 2
lcom 0
cbo 0
dl 0
loc 32
ccs 22
cts 22
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B executeCommand() 0 24 6
1
<?php
2
3
namespace App;
4
5
class Executor
6
{
7
8
	/**
9
	 * @param string|array $scriptPath
10
	 */
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
36
}
37