Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ListCategoriesController | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| list | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Expense\Infrastructure\Controllers; |
| 6 | |
| 7 | use App\Expense\Application\Query\ListCategoriesHandler; |
| 8 | use App\Expense\Application\Query\ListCategoriesQuery; |
| 9 | use OpenApi\Attributes as OA; |
| 10 | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
| 11 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 12 | use Symfony\Component\Routing\Attribute\Route; |
| 13 | |
| 14 | #[OA\Tag(name: 'Categories')] |
| 15 | class ListCategoriesController extends AbstractController |
| 16 | { |
| 17 | public function __construct( |
| 18 | private readonly ListCategoriesHandler $handler, |
| 19 | ) { |
| 20 | } |
| 21 | |
| 22 | /** The active categories, as the app must present them (labels/icons/colours). */ |
| 23 | #[Route('/categories', name: 'categories_list', methods: ['GET'])] |
| 24 | public function list(): JsonResponse |
| 25 | { |
| 26 | return new JsonResponse($this->handler->handle(new ListCategoriesQuery())); |
| 27 | } |
| 28 | } |