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
Read 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\AgentStat;
6
7use App\Controller\BaseController;
8use App\Entity\AgentStat;
9use App\Medal\MedalChecker;
10use App\Security\Voter\AgentStatVoter;
11use Symfony\Component\HttpFoundation\Response;
12use Symfony\Component\Routing\Attribute\Route;
13use Symfony\Component\Security\Http\Attribute\IsGranted;
14
15#[Route('/agent-stats/{id}', name: 'app_agent_stat_show', requirements: ['id' => '\d+'], methods: ['GET'])]
16#[IsGranted(AgentStatVoter::VIEW, subject: 'agentStat')]
17final class Read extends BaseController
18{
19    public function __invoke(AgentStat $agentStat, MedalChecker $medalChecker): Response
20    {
21        return $this->render('agent_stat/show.html.twig', [
22            'agent_stat' => $agentStat,
23            'medals' => $medalChecker->medalLevels($agentStat),
24            'coreBadges' => $medalChecker->coreBadges($agentStat->getStats()['months_subscribed'] ?? 0),
25        ]);
26    }
27}