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

AccessTokenParser::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
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