Passed
Push — develop ( cfccb6...0b3512 )
by BENARD
04:54
created

Download   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
dl 0
loc 22
rs 10
c 1
b 0
f 0

2 Methods

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