1 | <?php |
||
24 | class SeparateProcessExecutor implements ExecutorInterface |
||
25 | { |
||
26 | /** |
||
27 | * @var TaskHandlerFactoryInterface |
||
28 | */ |
||
29 | private $handlerFactory; |
||
30 | |||
31 | /** |
||
32 | * @var TaskExecutionRepositoryInterface |
||
33 | */ |
||
34 | private $executionRepository; |
||
35 | |||
36 | /** |
||
37 | * @var ExecutionProcessFactory |
||
38 | */ |
||
39 | private $processFactory; |
||
40 | |||
41 | /** |
||
42 | * @param TaskHandlerFactoryInterface $handlerFactory |
||
43 | * @param TaskExecutionRepositoryInterface $executionRepository |
||
44 | * @param ExecutionProcessFactory $processFactory |
||
45 | */ |
||
46 | 18 | public function __construct( |
|
55 | |||
56 | /** |
||
57 | * {@inheritdoc} |
||
58 | */ |
||
59 | 7 | public function execute(TaskExecutionInterface $execution) |
|
82 | |||
83 | /** |
||
84 | * Returns maximum attempts for specified handler. |
||
85 | * |
||
86 | * @param string $handlerClass |
||
87 | * |
||
88 | * @return int |
||
89 | */ |
||
90 | 7 | private function getMaximumAttempts($handlerClass) |
|
99 | |||
100 | /** |
||
101 | * Handle execution by using console-command. |
||
102 | * |
||
103 | * @param TaskExecutionInterface $execution |
||
104 | * |
||
105 | * @return string |
||
106 | * |
||
107 | * @throws FailedException |
||
108 | * @throws SeparateProcessException |
||
109 | */ |
||
110 | 7 | private function handle(TaskExecutionInterface $execution) |
|
121 | |||
122 | /** |
||
123 | * Create the correct exception. |
||
124 | * |
||
125 | * FailedException for failed executions. |
||
126 | * SeparateProcessExceptions for any exception during execution. |
||
127 | * |
||
128 | * @param string $errorOutput |
||
129 | * |
||
130 | * @return FailedException|SeparateProcessException |
||
131 | */ |
||
132 | 5 | private function createException($errorOutput) |
|
142 | } |
||
143 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: