Failed Conditions
Push — master ( 01d6ae...9ca6d9 )
by Philippe
534:14 queued 469:10
created

ProcessFailedException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 34
rs 10
c 0
b 0
f 0
ccs 14
cts 16
cp 0.875
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getProcess() 0 3 1
A __construct() 0 21 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpSpellcheck\Exception;
6
7
use Symfony\Component\Process\Process;
8
9
class ProcessFailedException extends \RuntimeException implements ExceptionInterface
10
{
11 2
    /**
12
     * @var Process
13
     */
14
    private $process;
15
16
    public function __construct(
17 2
        Process $process,
18
        \Throwable $previous = null,
19 2
        string $failureReason = "",
20 2
        int $code = 0
21 2
    ) {
22 2
        $this->process = $process;
23 2
24 2
        $message = \Safe\sprintf(
25 2
            'Process with command "%s" has failed%s with exit code %d(%s)%s',
26
            $process->getCommandLine(),
27
            $process->isStarted() ? ' running' : '',
28 2
            $process->getExitCode(),
29 2
            $process->getExitCodeText(),
30 2
            $failureReason ? ' because "' . $failureReason . '"' : ''
31 2
        );
32
33 2
        parent::__construct(
34
            $message,
35
            $code,
36
            $previous
37
        );
38
    }
39
40
    public function getProcess(): Process
41
    {
42
        return $this->process;
43
    }
44
}
45