Lines 100.00% 5 / 5
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
Index 100.00% 5 / 5 100.00% 1 / 1 1 100.00% 1 / 1
 __invoke 100.00% 5 / 5 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Controller\Agent;
6
7use App\Controller\BaseController;
8use App\Enum\UserRole;
9use App\Repository\AgentStatRepository;
10use App\Repository\UserRepository;
11use Symfony\Component\HttpFoundation\Response;
12use Symfony\Component\Routing\Attribute\Route;
13use Symfony\Component\Security\Http\Attribute\IsGranted;
14
15/**
16 * The agents who show their profile to other users (admins too; every user is on User\\Index).
17 */
18#[Route('/agents', name: 'app_agent_index', methods: ['GET'])]
19#[IsGranted(UserRole::USER->value)]
20final class Index extends BaseController
21{
22    public function __invoke(UserRepository $userRepository, AgentStatRepository $agentStatRepository): Response
23    {
24        $agents = $userRepository->findVisibleAgents();
25
26        return $this->render('agent/index.html.twig', [
27            'agents' => $agents,
28            'latest' => $agentStatRepository->findLatestByOwners($agents),
29        ]);
30    }
31}