Shell::setCommand()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace pmill\Scheduler\Tasks;
3
4
class Shell extends Task
5
{
6
    /**
7
     * @var string
8
     */
9
    protected $command;
10
11
    /**
12
     * @var array
13
     */
14
    protected $arguments = [];
15
16
    /**
17
     * @return mixed
18
     */
19
    public function run()
20
    {
21
        $output = null;
22
        exec($this->getCommand().' '.implode(' ', $this->arguments), $output, $result);
23
             
24
        $this->setOutput($output);
25
        return $result;
26
    }
27
28
    /**
29
     * @param string $command
30
     * @return $this
31
     */
32
    public function setCommand($command)
33
    {
34
        $this->command = $command;
35
        return $this;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getCommand()
42
    {
43
        return $this->command;
44
    }
45
46
    /**
47
     * @param mixed $argument
48
     * @return $this
49
     */
50
    public function addArgument($argument)
51
    {
52
        $this->arguments[] = $argument;
53
        return $this;
54
    }
55
56
    /**
57
     * @return array
58
     */
59
    public function getArguments()
60
    {
61
        return $this->arguments;
62
    }
63
64
}