Passed
Push — master ( 84533f...cb764e )
by Marco Aurélio
02:53
created

src/CognitoUserProvider.php (3 issues)

1
<?php declare(strict_types=1);
2
3
namespace CustomerGauge\Cognito;
4
5
use CustomerGauge\Cognito\Parsers\ClientAppParser;
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 $clientAppParser;
13
14
    private $accessTokenParser;
15
16 1
    public function __construct(ClientAppParser $clientAppParser/*, AccessTokenParser $accessTokenParser*/)
17
    {
18 1
        $this->clientAppParser = $clientAppParser;
19
//        $this->accessTokenParser = $accessTokenParser;
20 1
    }
21
22 1
    public function retrieveByCredentials(array $credentials)
23
    {
24 1
        $token = $credentials['cognito_token'];
25
26
        try {
27 1
            return $this->clientAppParser->parse($token);
28
        } catch (Exception $e) {
29
var_dump($e->getMessage());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($e->getMessage()) looks like debug code. Are you sure you do not want to remove it?
Loading history...
30
exit;
0 ignored issues
show
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
31
        }
32
/*
33
        try {
34
            return $this->accessTokenParser->parse($token);
35
        } catch (Exception $e) {
36
37
        }
38
*/
39
        return null;
0 ignored issues
show
return null is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
40
    }
41
42
    /** @phpstan ignore */
43
    public function validateCredentials(Authenticatable $user, array $credentials)
44
    {
45
    }
46
47
    /** @phpstan ignore */
48
    public function retrieveById($identifier)
49
    {
50
    }
51
52
    /** @phpstan ignore */
53
    public function retrieveByToken($identifier, $token)
54
    {
55
    }
56
57
    /** @phpstan ignore */
58
    public function updateRememberToken(Authenticatable $user, $token)
59
    {
60
    }
61
}
62