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