ReallySimpleJWTValidateToken::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Auth\Infrastructure\Service;
6
7
use Auth\Container\TokenConfig;
8
use Auth\Model\Payload;
9
use Auth\Model\Token;
10
use Auth\Service\ValidateToken;
11
use ReallySimpleJWT\Token as Jwt;
12
13
class ReallySimpleJWTValidateToken implements ValidateToken
14
{
15
    private $secret;
16
17
    public function __construct(TokenConfig $config)
18
    {
19
        $this->secret = $config->secret();
20
    }
21
22
    public function __invoke(Token $token): Payload
23
    {
24
        Jwt::validate((string)$token, $this->secret);
25
26
        return Payload::fromJsonString(
27
            Jwt::getPayload((string)$token)
28
        );
29
    }
30
}
31