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

SearchController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 12
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 1
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