Search   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 20
ccs 9
cts 9
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller\Task;
6
7
use Slim\Http\Request;
8
use Slim\Http\Response;
9
10
final class Search extends Base
11
{
12 4
    /**
13
     * @param array<string> $args
14 4
     */
15 4
    public function __invoke(
16 4
        Request $request,
17 4
        Response $response,
18 1
        array $args
19
    ): Response {
20 4
        $input = (array) $request->getParsedBody();
21 4
        $userId = $this->getAndValidateUserId($input);
22
        $query = '';
23 4
        if (isset($args['query'])) {
24
            $query = $args['query'];
25
        }
26
        $status = $request->getParam('status', null);
27
        $tasks = $this->getTaskService()->search($query, $userId, $status);
28
29
        return $this->jsonResponse($response, 'success', $tasks, 200);
30
    }
31
}
32