Total Complexity | 6 |
Total Lines | 69 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | abstract class ChurnProcess implements ProcessInterface |
||
15 | { |
||
16 | /** |
||
17 | * The file the process will be executed on. |
||
18 | * |
||
19 | * @var File |
||
20 | */ |
||
21 | protected $file; |
||
22 | |||
23 | /** |
||
24 | * The Symfony Process Component. |
||
25 | * |
||
26 | * @var Process |
||
27 | */ |
||
28 | protected $process; |
||
29 | |||
30 | /** |
||
31 | * Class constructor. |
||
32 | * |
||
33 | * @param File $file The file the process is being executed on. |
||
34 | * @param Process $process The process being executed on the file. |
||
35 | */ |
||
36 | public function __construct(File $file, Process $process) |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Start the process. |
||
44 | */ |
||
45 | #[\Override] |
||
46 | public function start(): void |
||
47 | { |
||
48 | $this->process->start(); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Determines if the process was successful. |
||
53 | * |
||
54 | * @throws ProcessFailedException If the process failed. |
||
55 | */ |
||
56 | #[\Override] |
||
57 | public function isSuccessful(): bool |
||
58 | { |
||
59 | $exitCode = $this->process->getExitCode(); |
||
60 | |||
61 | if ($exitCode > 0) { |
||
62 | throw new ProcessFailedException($this->process); |
||
63 | } |
||
64 | |||
65 | return 0 === $exitCode; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Gets the file the process is being executed on. |
||
70 | */ |
||
71 | #[\Override] |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Gets the output of the process. |
||
79 | */ |
||
80 | protected function getOutput(): string |
||
83 | } |
||
84 | } |
||
85 |