Completed
Pull Request — master (#5)
by Dan Michael O.
12:38 queued 10:10
created

CommandException   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 68.75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 36
ccs 11
cts 16
cp 0.6875
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 2
A getCommand() 0 4 1
A getOutput() 0 4 1
A getReturnCode() 0 4 1
1
<?php
2
namespace pastuhov\Command;
3
4
class CommandException extends \RuntimeException
5
{
6
    protected $command;
7
    protected $output;
8
    protected $returnCode;
9
10 3
    public function __construct($command, $output, $returnCode)
11
    {
12 3
        $this->command = $command;
13 3
        $this->output = $output;
14 3
        $this->returnCode = $returnCode;
15
16 3
        if ($this->returnCode == 127) {
17 3
            $message = 'Command not found: "' . $this->getCommand() . '"';
18 3
        } else {
19
            $message = 'Command "' . $this->getCommand() . '" exited with code ' . $this->getReturnCode() . ': ' . $this->getOutput();
20
        }
21
22 3
        parent::__construct($message);
23 3
    }
24
25 3
    public function getCommand()
26
    {
27 3
        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