Token   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
eloc 11
dl 0
loc 19
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 17 1
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\ApiGwAuthenticationUser;
15
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
16
use Symfony\Component\HttpFoundation\JsonResponse;
17
18
final class Token
19
{
20
    public function __invoke(JWTTokenManagerInterface $jwtManager): JsonResponse
21
    {
22
        $username = uniqid('user_');
23
24
        $payload = [
25
            'iat' => time(),
26
            'sub' => $username,
27
            'jti' => uniqid(),
28
            'iss' => '/api/token',
29
            'foo' => 'bar',
30
        ];
31
32
        $user = new ApiGwAuthenticationUser($username);
33
34
        return new JsonResponse(
35
            [
36
                'token' => $jwtManager->createFromPayload($user, $payload),
0 ignored issues
show
Bug introduced by
The method createFromPayload() does not exist on Lexik\Bundle\JWTAuthenti...WTTokenManagerInterface. Did you maybe mean create()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
                'token' => $jwtManager->/** @scrutinizer ignore-call */ createFromPayload($user, $payload),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
            ]
38
        );
39
    }
40
}
41