CognitoUserProvider::validateCredentials()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 2
ccs 0
cts 1
cp 0
crap 2
rs 10
1
<?php declare(strict_types=1);
2
3
namespace CustomerGauge\Cognito;
4
5
use CustomerGauge\Cognito\Contracts\UserFactory;
6
use Exception;
7
use Illuminate\Contracts\Auth\Authenticatable;
8
use Illuminate\Contracts\Auth\UserProvider;
9
10
final class CognitoUserProvider implements UserProvider
11
{
12
    private $parser;
13
14
    private $factory;
15
16 4
    public function __construct(TokenParser $parser, UserFactory $factory)
17
    {
18 4
        $this->parser = $parser;
19 4
        $this->factory = $factory;
20
    }
21
22 4
    public function retrieveByCredentials(array $credentials)
23
    {
24 4
        $token = $credentials['cognito_token'];
25
26
        try {
27 4
            $payload = $this->parser->parse($token);
28
29 1
        } catch (Exception $e) {
30
            // If we cannot parse the token, that probably means it's an invalid Token. Since
31
            // the Authenticate Middleware implements a Chain Of Responsibility Pattern,
32
            // we have to return null so that other Guards can try to authenticate.
33 1
            return null;
34
        }
35
36 3
        return $this->factory->make($payload);
37
    }
38
39
    /** @phpstan ignore */
40
    public function validateCredentials(Authenticatable $user, array $credentials)
41
    {
42
    }
43
44
    /** @phpstan ignore */
45
    public function retrieveById($identifier)
46
    {
47
    }
48
49
    /** @phpstan ignore */
50
    public function retrieveByToken($identifier, $token)
51
    {
52
    }
53
54
    /** @phpstan ignore */
55
    public function updateRememberToken(Authenticatable $user, $token)
56
    {
57
    }
58
}
59