Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Index
100.00% covered (success)
100.00%
10 / 10
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%
9 / 9
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace App\Controller\PaymentMethods;
6
7use App\Controller\BaseController;
8use App\Repository\PaymentMethodRepository;
9use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\HttpFoundation\Response;
11use Symfony\Component\Routing\Attribute\Route;
12use Symfony\Component\Security\Http\Attribute\IsGranted;
13
14#[IsGranted('ROLE_ADMIN')]
15#[Route(path: '/payment-methods', name: 'payment_methods_index', methods: ['GET'])]
16class Index extends BaseController
17{
18    public function __construct(private readonly PaymentMethodRepository $repository) {}
19
20    public function __invoke(
21        Request $request
22    ): Response
23    {
24        $template = $request->query->get('ajax')
25            ? '_list.html.twig'
26            : 'list.html.twig';
27
28        return $this->render(
29            'payment-methods/'.$template,
30            [
31                'paymentMethods' => $this->repository->findAll(),
32            ]
33        );
34    }
35}