Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Index
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
2 / 2
2
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%
14 / 14
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Controller\Deposits;
6
7use App\Controller\BaseController;
8use App\Helper\Paginator\PaginatorTrait;
9use App\Repository\DepositRepository;
10use Symfony\Component\DependencyInjection\Attribute\Autowire;
11use Symfony\Component\HttpFoundation\Request;
12use Symfony\Component\HttpFoundation\Response;
13use Symfony\Component\Routing\Attribute\Route;
14use Symfony\Component\Security\Http\Attribute\IsGranted;
15use function count;
16
17#[IsGranted('ROLE_ADMIN')]
18#[Route(path: '/deposits', name: 'deposits_index', methods: ['GET', 'POST'])]
19class Index extends BaseController
20{
21    use PaginatorTrait;
22
23    public function __construct(private readonly DepositRepository $depositRepository) {}
24
25    public function __invoke(
26        Request $request,
27        #[Autowire('%env(LIST_LIMIT)%')] int $listLimit,
28    ): Response
29    {
30        $paginatorOptions = $this->getPaginatorOptions($request, $listLimit);
31        $deposits = $this->depositRepository->getPaginatedList($paginatorOptions);
32        $paginatorOptions->setMaxPages(
33            (int)ceil(
34                count($deposits) / $paginatorOptions->getLimit()
35            )
36        );
37
38        return $this->render(
39            'deposit/list.html.twig',
40            [
41                'deposits' => $deposits,
42                'paginatorOptions' => $paginatorOptions,
43            ]
44        );
45    }
46}