Exec::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 1
1
<?php
2
3
4
namespace Genesis\Commands;
5
6
7
use Genesis\Cli;
8
9
/**
10
 * @author Adam Bisek <[email protected]>
11
 */
12
class Exec extends Command
13
{
14
15
	private $command;
16
17
18
	/**
19
	 * Returns setted shell command
20
	 * @return mixed
21
	 */
22
	public function getCommand()
23
	{
24
		return $this->command;
25
	}
26
27
28
	/**
29
	 * Sets shell command (to be executed later)
30
	 * @param mixed $command
31
	 */
32 10
	public function setCommand($command)
33
	{
34 10
		$this->command = $command;
35 10
	}
36
37
38
	/**
39
	 * @return ExecResult
40
	 */
41 10
	public function execute()
42
	{
43 10
		echo Cli::getColoredString($this->command . PHP_EOL, 'light_blue');
44 10
		exec($this->command, $output, $return);
45 10
		$result = new ExecResult($return, $output);
46 10
		echo Cli::getColoredString(implode(PHP_EOL, $output), 'dark_gray') . "\n\n";
47 10
		return $result;
48
	}
49
50
}