Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Payments
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __invoke
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace App\Controller\Admin;
6
7use App\Controller\BaseController;
8use App\Repository\TransactionRepository;
9use Symfony\Component\Clock\ClockInterface;
10use Symfony\Component\HttpFoundation\Request;
11use Symfony\Component\HttpFoundation\Response;
12use Symfony\Component\Routing\Attribute\Route;
13use Symfony\Component\Security\Http\Attribute\IsGranted;
14
15#[Route(path: '/admin/payments', name: 'admin_payments', methods: ['GET'])]
16#[IsGranted('ROLE_CASHIER')]
17class Payments extends BaseController
18{
19    public function __construct(
20        private readonly TransactionRepository $repository,
21        private readonly ClockInterface $clock,
22    ) {}
23
24    public function __invoke(Request $request): Response
25    {
26        $now = $this->clock->now();
27        $currentYear = (int) $now->format('Y');
28        $year = $request->query->getInt('year', $currentYear);
29        $month = $year === $currentYear ? (int) $now->format('m') : 1;
30
31        return $this->render(
32            'admin/payments.html.twig',
33            [
34                'year' => $year,
35                'month' => $month,
36                'transactions' => $this->repository->getPagosPorAno($year),
37            ]
38        );
39    }
40}