Show   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A download() 0 4 1
A __construct() 0 2 1
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