1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Soluble\MediaTools\Exception; |
||
6 | |||
7 | use Symfony\Component\Process\Exception as SPException; |
||
8 | use Symfony\Component\Process\Process; |
||
9 | |||
10 | class ProcessException extends RuntimeException implements ProcessExceptionInterface |
||
11 | { |
||
12 | /** @var Process */ |
||
13 | protected $process; |
||
14 | |||
15 | public function __construct(Process $process, SPException\RuntimeException $previousException) |
||
16 | { |
||
17 | if ($previousException instanceof SPException\ProcessFailedException || |
||
18 | $previousException instanceof SPException\ProcessTimedOutException || |
||
19 | $previousException instanceof SPException\ProcessSignaledException |
||
20 | ) { |
||
21 | $code = $previousException->getProcess()->getExitCode(); |
||
22 | } else { |
||
23 | $code = 1; |
||
24 | } |
||
25 | |||
26 | parent::__construct( |
||
27 | $previousException->getMessage(), |
||
28 | $code, |
||
29 | $previousException |
||
30 | ); |
||
31 | |||
32 | $this->process = $process; |
||
0 ignored issues
–
show
|
|||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Return symfony process object. |
||
37 | */ |
||
38 | public function getProcess(): Process |
||
39 | { |
||
40 | return $this->process; |
||
41 | } |
||
42 | |||
43 | public function geErrorOutput(): string |
||
44 | { |
||
45 | return $this->process->getErrorOutput(); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @return SPException\RuntimeException|SPException\ProcessFailedException|SPException\ProcessSignaledException|SPException\ProcessTimedOutException |
||
50 | */ |
||
51 | public function getSymfonyProcessRuntimeException(): SPException\RuntimeException |
||
52 | { |
||
53 | /** |
||
54 | * @var SPException\RuntimeException |
||
55 | */ |
||
56 | $previous = $this->getPrevious(); |
||
57 | |||
58 | return $previous; |
||
59 | } |
||
60 | } |
||
61 |
This check looks for improperly formatted assignments.
Every assignment must have exactly one space before and one space after the equals operator.
To illustrate:
will have no issues, while
will report issues in lines 1 and 2.