Passed
Push — master ( cd44eb...37d45b )
by Ger
10:22
created

SearchController::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 10
rs 10
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace App\Http\Controllers\Search;
6
7
use App\Http\Controllers\Controller;
8
use Illuminate\Http\JsonResponse;
9
use Illuminate\Http\Request;
10
use TrophyForum\Searches\Application\Search\SearchQuery;
11
use TrophyForum\Searches\Application\Search\SearchQueryHandler;
12
13
final class SearchController extends Controller
14
{
15
    public function __invoke(Request $request): JsonResponse
16
    {
17
        $this->bus->addHandler(SearchQuery::class, SearchQueryHandler::class);
18
19
        return JsonResponse::create(
20
            $this->bus->dispatch(
21
                new SearchQuery(
22
                    (int) $request->get('page', 1),
23
                    $request->get('keyword', null),
24
                    $request->get('author', null)
25
                )
26
            )
27
        );
28
    }
29
}
30