Passed
Pull Request — master (#5)
by Aleksandr
02:11
created

CommandException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
dl 0
loc 27
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sanchescom\WiFi\Exceptions;
6
7
use RuntimeException;
8
9
/**
10
 * Class CommandException.
11
 */
12
class CommandException extends RuntimeException
13
{
14
    /** @var string */
15
    protected $command;
16
17
    /** @var string */
18
    protected $output;
19
20
    /** @var int */
21
    protected $returnCode;
22
23
    /**
24
     * CommandException constructor.
25
     *
26
     * @param string $command
27
     * @param string $output
28
     * @param int    $returnCode
29
     */
30
    public function __construct(string $command, string $output, int $returnCode)
31
    {
32
        if ($this->returnCode == 127) {
33
            $message = 'Command not found: "'.$command.'"';
34
        } else {
35
            $message = 'Command "'.$command.'" exited with code '.$returnCode.': '.$output;
36
        }
37
38
        parent::__construct($message);
39
    }
40
}
41