Total Complexity | 5 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | final class UserAuth implements AuthenticationMethodInterface |
||
18 | { |
||
19 | private string $authUrl = '/login'; |
||
20 | |||
21 | 7 | public function __construct(private CurrentUser $currentUser, private ResponseFactoryInterface $responseFactory) |
|
22 | { |
||
23 | 7 | } |
|
24 | |||
25 | 2 | public function authenticate(ServerRequestInterface $request): ?IdentityInterface |
|
26 | { |
||
27 | 2 | if ($this->currentUser->isGuest()) { |
|
28 | 1 | return null; |
|
29 | } |
||
30 | |||
31 | 1 | return $this->currentUser->getIdentity(); |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * {@inheritDoc} |
||
36 | * |
||
37 | * Creates a new instance of the response and adds a `Location` header with a temporary redirect. |
||
38 | */ |
||
39 | 2 | public function challenge(ResponseInterface $response): ResponseInterface |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * Returns a new instance with the specified authentication URL. |
||
48 | * |
||
49 | * @param string $url The authentication URL. |
||
50 | */ |
||
51 | 4 | public function withAuthUrl(string $url): self |
|
56 | } |
||
57 | } |
||
58 |