Passed
Branch master (c65b3c)
by Jan
05:40 queued 01:37
created

Executor   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 4
c 2
b 1
f 1
lcom 0
cbo 0
dl 0
loc 25
ccs 0
cts 16
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A executeCommand() 0 17 4
1
<?php
2
3
namespace App;
4
5
class Executor
6
{
7
8
	/**
9
	 * @param string|array $scriptPath
10
	 */
11
	public function executeCommand($scriptPath, array $env)
12
	{
13
		$oldCwd = NULL;
14
		if (is_array($scriptPath)) {
15
			$cwd = $scriptPath['cwd'];
16
			$scriptPath = $scriptPath['command'];
17
			$oldCwd = getcwd();
18
			chdir($cwd);
19
		}
20
		foreach ($env as $key => $value) {
21
			putenv($key . '=' . $value);
22
		}
23
		shell_exec($scriptPath);
24
		if ($oldCwd !== NULL) {
25
			chdir($oldCwd);
26
		}
27
	}
28
29
}
30