| Total Complexity | 7 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Coverage | 94.74% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class ProcessException extends RuntimeException implements ProcessExceptionInterface |
||
| 11 | { |
||
| 12 | /** @var Process */ |
||
| 13 | protected $process; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @param string|null $message if not set will use the previousException message |
||
| 17 | */ |
||
| 18 | 12 | public function __construct(Process $process, SPException\RuntimeException $previousException, ?string $message = null) |
|
| 19 | { |
||
| 20 | 12 | if ($previousException instanceof SPException\ProcessFailedException || |
|
| 21 | 5 | $previousException instanceof SPException\ProcessTimedOutException || |
|
| 22 | 12 | $previousException instanceof SPException\ProcessSignaledException |
|
| 23 | ) { |
||
| 24 | 12 | $code = $previousException->getProcess()->getExitCode(); |
|
| 25 | } else { |
||
| 26 | $code = 1; |
||
| 27 | } |
||
| 28 | |||
| 29 | 12 | $msg = $message ?? $previousException->getMessage(); |
|
| 30 | |||
| 31 | 12 | parent::__construct( |
|
| 32 | 12 | $msg, |
|
| 33 | 12 | $code ?? 1, |
|
| 34 | $previousException |
||
| 35 | ); |
||
| 36 | |||
| 37 | 12 | $this->process = $process; |
|
| 38 | 12 | } |
|
| 39 | |||
| 40 | /** |
||
| 41 | * Return symfony process object. |
||
| 42 | */ |
||
| 43 | 1 | public function getProcess(): Process |
|
| 44 | { |
||
| 45 | 1 | return $this->process; |
|
| 46 | } |
||
| 47 | |||
| 48 | 1 | public function getErrorOutput(): string |
|
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @return SPException\RuntimeException|SPException\ProcessFailedException|SPException\ProcessSignaledException|SPException\ProcessTimedOutException |
||
| 55 | */ |
||
| 56 | 1 | public function getSymfonyProcessRuntimeException(): SPException\RuntimeException |
|
| 64 | } |
||
| 65 | } |
||
| 66 |