Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 4 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| SetController | |
0.00% |
0 / 5 |
|
0.00% |
0 / 4 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| searchSet | |
0.00% |
0 / 4 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\CollectionManagement\Infrastructure\Controller; |
| 4 | |
| 5 | use App\CollectionManagement\Application\Command\SearchSetQuery; |
| 6 | use App\CollectionManagement\Application\Handler\SearchSetHandler; |
| 7 | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
| 8 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 9 | use Symfony\Component\HttpFoundation\Request; |
| 10 | use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
| 11 | use Symfony\Component\Routing\Attribute\Route; |
| 12 | |
| 13 | #[Route('/api')] |
| 14 | final class SetController extends AbstractController |
| 15 | { |
| 16 | public function __construct( |
| 17 | private readonly SearchSetHandler $searchSetHandler |
| 18 | ) |
| 19 | {} |
| 20 | |
| 21 | #[Route('/sets', methods: ['GET', 'HEAD'])] |
| 22 | public function searchSet(Request $request): JsonResponse |
| 23 | { |
| 24 | if(!$request->query->has('q')) { |
| 25 | throw new BadRequestHttpException(); |
| 26 | } |
| 27 | $query = new SearchSetQuery($request->get('q')); |
| 28 | return $this->json(($this->searchSetHandler)($query)); |
| 29 | } |
| 30 | } |