| Total Complexity | 7 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 56.25% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 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) |
||
| 42 | } |
||
| 43 | |||
| 44 | /** @phpstan ignore */ |
||
| 45 | public function retrieveById($identifier) |
||
| 46 | { |
||
| 47 | } |
||
| 48 | |||
| 49 | /** @phpstan ignore */ |
||
| 50 | public function retrieveByToken($identifier, $token) |
||
| 52 | } |
||
| 53 | |||
| 54 | /** @phpstan ignore */ |
||
| 55 | public function updateRememberToken(Authenticatable $user, $token) |
||
| 59 |