| Conditions | 4 |
| Paths | 5 |
| Total Lines | 24 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | 3 | public function __invoke(HttpServer $server, int $taskId, int $fromId, $task): void |
|
| 29 | { |
||
| 30 | 3 | if (! $task instanceof TaskInterface) { |
|
| 31 | 1 | $this->logger->warning('Invalid task provided to task worker: {type}. Task ignored', [ |
|
| 32 | 1 | 'type' => is_object($task) ? get_class($task) : gettype($task), |
|
| 33 | ]); |
||
| 34 | 1 | $server->finish(''); |
|
| 35 | 1 | return; |
|
| 36 | } |
||
| 37 | |||
| 38 | 2 | $this->logger->notice('Starting work on task {taskId}: {task}', [ |
|
| 39 | 2 | 'taskId' => $taskId, |
|
| 40 | 2 | 'task' => $task->toString(), |
|
| 41 | ]); |
||
| 42 | |||
| 43 | try { |
||
| 44 | 2 | $task->run($this->container); |
|
| 45 | 1 | } catch (Throwable $e) { |
|
| 46 | 1 | $this->logger->error('Error processing task {taskId}: {e}', [ |
|
| 47 | 1 | 'taskId' => $taskId, |
|
| 48 | 1 | 'e' => $e, |
|
| 49 | ]); |
||
| 50 | 2 | } finally { |
|
| 51 | 2 | $server->finish(''); |
|
| 52 | } |
||
| 55 |