AvatarDownload   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 12
c 0
b 0
f 0
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VideoGamesRecords\CoreBundle\Controller\Team\Avatar;
6
7
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8
use Symfony\Component\HttpFoundation\StreamedResponse;
9
use Symfony\Component\Routing\Attribute\Route;
10
use VideoGamesRecords\CoreBundle\Entity\Team;
11
use VideoGamesRecords\CoreBundle\Manager\AvatarManager;
12
13
class AvatarDownload extends AbstractController
14
{
15
    private AvatarManager $avatarManager;
16
17
18
    public function __construct(AvatarManager $avatarManager)
19
    {
20
        $this->avatarManager = $avatarManager;
21
    }
22
23
    #[Route(
24
        '/teams/{id}/avatar',
25
        name: 'vgr_core_team_avatar',
26
        methods: ['GET'],
27
        requirements: ['id' => '[1-9]\d*']
28
    )]
29
    public function __invoke(Team $team): StreamedResponse
30
    {
31
        $response = $this->avatarManager->read($team->getLogo());
32
        $response->setPublic();
33
        $response->setMaxAge(3600);
34
        return $response;
35
    }
36
}
37