CommandFailedException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 32
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
A getProcess() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the systemctl PHP library.
7
 *
8
 * (c) Martin Janser <[email protected]>
9
 *
10
 * This source file is subject to the GPL license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13
14
namespace SystemCtl;
15
16
use Symfony\Component\Process\Process;
17
18
class CommandFailedException extends \RuntimeException
19
{
20
    /**
21
     * @var Process
22
     */
23
    private $process;
24
25
    /**
26
     * @param Process $process
27
     */
28 25
    public function __construct(Process $process)
29
    {
30 25
        $this->process = $process;
31
32 25
        $message = sprintf(
33 25
            'Command "%s" failed with code %s, error returned: %s',
34 25
            $this->process->getCommandLine(),
35 25
            $this->process->getExitCode(),
36 25
            $this->process->getErrorOutput()
37
        );
38
39 25
        parent::__construct($message, $this->process->getExitCode());
40 25
    }
41
42
    /**
43
     * @return Process
44
     */
45 5
    public function getProcess()
46
    {
47 5
        return $this->process;
48
    }
49
}
50