Total Complexity | 4 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class AsyncChildCommand extends Command |
||
14 | { |
||
15 | public const COMMAND_NAME = 'app:run-child-process'; |
||
16 | private const PARAM_NAME_JOB = 'job'; |
||
17 | private $serializer; |
||
18 | |||
19 | public function __construct(?string $name = null) |
||
20 | { |
||
21 | parent::__construct($name); |
||
22 | |||
23 | $this->serializer = new Serializer(); |
||
24 | } |
||
25 | |||
26 | public function execute(InputInterface $input, OutputInterface $output): int |
||
27 | { |
||
28 | try { |
||
29 | $job = $this->serializer->unserialize(base64_decode($input->getArgument(self::PARAM_NAME_JOB))); |
||
|
|||
30 | |||
31 | ob_start(); |
||
32 | $jobResults = $job(); |
||
33 | $ob = ob_get_clean(); |
||
34 | $error = null; |
||
35 | } catch (Exception $exception) { |
||
36 | $jobResults = null; |
||
37 | $ob = null; |
||
38 | $error = $exception; |
||
39 | } |
||
40 | |||
41 | $output->writeln(base64_encode(serialize(new AsyncChildResponse($jobResults, $ob, $error)))); |
||
42 | |||
43 | return 0; |
||
44 | } |
||
45 | |||
46 | protected function configure(): void |
||
52 | } |
||
53 | } |