Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ReportController | |
100.00% |
8 / 8 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __invoke | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Controller; |
| 4 | |
| 5 | use App\Application\UseCase\CreateReportInterface; |
| 6 | use App\Dto\Command\CreateReportCommand; |
| 7 | use App\Dto\Request\ReportRequest; |
| 8 | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
| 9 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 10 | use Symfony\Component\HttpFoundation\Response; |
| 11 | use Symfony\Component\HttpKernel\Attribute\MapRequestPayload; |
| 12 | use Symfony\Component\Routing\Attribute\Route; |
| 13 | |
| 14 | /** |
| 15 | * @author Wilhelm Zwertvaegher |
| 16 | */ |
| 17 | #[Route('/api/report')] |
| 18 | class ReportController extends AbstractController |
| 19 | { |
| 20 | public function __construct(private readonly CreateReportInterface $report) |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | #[Route('', name: 'api_report', methods: ['POST'])] |
| 25 | public function __invoke(#[MapRequestPayload] ReportRequest $request): JsonResponse |
| 26 | { |
| 27 | $reportCommand = new CreateReportCommand( |
| 28 | $request->getSenderEmail(), |
| 29 | $request->getReason(), |
| 30 | $request->getNickId() |
| 31 | ); |
| 32 | ($this->report)($reportCommand); |
| 33 | |
| 34 | return new JsonResponse(null, Response::HTTP_CREATED); |
| 35 | } |
| 36 | } |