Completed
Push — master ( fbf162...5c7a71 )
by Kirill
9s
created

CommandException::getOutput()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace pastuhov\Command;
3
4
class CommandException extends \RuntimeException
5
{
6
    protected $command;
7
    protected $output;
8
    protected $returnCode;
9
10
    public function __construct($command, $output, $returnCode)
11
    {
12
        $this->command = $command;
13
        $this->output = $output;
14
        $this->returnCode = $returnCode;
15
16
        if ($this->returnCode == 127) {
17
            $message = 'Command not found: "' . $this->getCommand() . '"';
18
        } else {
19
            $message = 'Command "' . $this->getCommand() . '" exited with code ' . $this->getReturnCode() . ': ' . $this->getOutput();
20
        }
21
22
        parent::__construct($message);
23
    }
24
25
    public function getCommand()
26
    {
27
        return $this->command;
28
    }
29
30
    public function getOutput()
31
    {
32
        return $this->output;
33
    }
34
35
    public function getReturnCode()
36
    {
37
        return $this->returnCode;
38
    }
39
}
40