User   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 11
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 2
1
<?php
2
3
/**
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 *
7
 * @see https://github.com/ecphp
8
 */
9
10
declare(strict_types=1);
11
12
namespace EcPhp\ApiGwAuthenticationBundle\Controller;
13
14
use EcPhp\ApiGwAuthenticationBundle\Security\Core\User\ApiGwAuthenticationUserInterface;
15
use Symfony\Component\HttpFoundation\JsonResponse;
16
use Symfony\Component\Security\Core\Security;
17
18
final class User
19
{
20
    public function __invoke(Security $security): JsonResponse
21
    {
22
        $user = $security->getUser();
23
24
        if ($user instanceof ApiGwAuthenticationUserInterface) {
25
            return new JsonResponse($user->getAttributes());
26
        }
27
28
        return new JsonResponse([], 404);
29
    }
30
}
31