Passed
Push — master ( 6fa43b...67ed79 )
by Marco Aurélio
03:25
created

AccessTokenParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 17
ccs 7
cts 7
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A parse() 0 5 1
1
<?php declare(strict_types=1);
2
3
namespace CustomerGauge\Cognito\Parsers;
4
5
use CustomerGauge\Cognito\Contracts\UserFactory;
6
use CustomerGauge\Cognito\TokenVerifier;
7
use Illuminate\Contracts\Auth\Authenticatable;
8
9
final class AccessTokenParser
10
{
11
    private $verifier;
12
13
    private $factory;
14
15 3
    public function __construct(TokenVerifier $verifier, UserFactory $factory)
16
    {
17 3
        $this->verifier = $verifier;
18 3
        $this->factory = $factory;
19 3
    }
20
21 2
    public function parse(string $token): Authenticatable
22
    {
23 2
        $payload = $this->verifier->verify($token);
24
25 1
        return $this->factory->fromAccessToken($payload);
26
    }
27
}
28