Show::download()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace ProjetNormandie\UserBundle\Controller\Avatar;
4
5
use League\Flysystem\FilesystemException;
6
use ProjetNormandie\UserBundle\Entity\User;
7
use ProjetNormandie\UserBundle\Service\AvatarManager;
8
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
9
use Symfony\Component\HttpFoundation\StreamedResponse;
10
use Symfony\Component\Routing\Annotation\Route;
11
12
#[Route('/users')]
13
class Show extends AbstractController
14
{
15
    public function __construct(private readonly AvatarManager $avatarManager)
16
    {
17
    }
18
19
    /**
20
     * @throws FilesystemException
21
     */
22
    #[Route('/{id}/avatar', name: 'pn_user_avatar_show', requirements: ['page' => '\d+'], stateless: false)]
23
    public function download(User $user): StreamedResponse
24
    {
25
        return $this->avatarManager->read($user->getAvatar());
26
    }
27
}
28