Conditions | 7 |
Paths | 6 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 7.2944 |
Changes | 0 |
1 | <?php |
||
18 | 2 | public function handle(ServerRequestInterface $request): ResponseInterface |
|
19 | { |
||
20 | 2 | $body = $request->getParsedBody(); |
|
21 | |||
22 | 2 | if (!isset($body['profile']) or !$profile = new Profile($body['profile'])) { |
|
23 | throw new \RuntimeException('Missing profile'); |
||
24 | } |
||
25 | |||
26 | 2 | if (!isset($body['job']) or !$job = new $body['job']) { |
|
27 | throw new \RuntimeException('Missing job'); |
||
28 | } |
||
29 | |||
30 | 2 | $parameters = isset($body['parameters']) ? $body['parameters'] : []; |
|
31 | |||
32 | 2 | $tags = isset($body['tags']) ? $body['tags'] : []; |
|
33 | |||
34 | 2 | $task = new Task($profile, $job, $parameters, $tags); |
|
35 | |||
36 | 2 | $this->queue->add($task); |
|
37 | |||
38 | 2 | return new JsonResponse($task, 201); |
|
39 | } |
||
41 |