CommandException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

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

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
    /**
21
     * CommandException constructor.
22
     *
23
     * @param string $command
24
     * @param string $output
25
     * @param int    $returnCode
26
     */
27
    public function __construct(string $command, string $output, int $returnCode)
28
    {
29
        if ($returnCode == 127) {
30
            $message = 'Command not found: "'.$command.'"';
31
        } else {
32
            $message = 'Command "'.$command.'" exited with code '.$returnCode.': '.$output;
33
        }
34
35
        parent::__construct($message);
36
    }
37
}
38