Authenticator::getUser()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Bundle\ApiAuthBundle\Security\ApiKey;
6
7
use Damax\Bundle\ApiAuthBundle\Security\AbstractAuthenticator;
8
use Symfony\Component\Security\Core\User\UserInterface;
9
use Symfony\Component\Security\Core\User\UserProviderInterface;
10
11
final class Authenticator extends AbstractAuthenticator
12
{
13
    public function getUser($credentials, UserProviderInterface $provider): UserInterface
14
    {
15
        if ($provider instanceof ApiKeyUserProvider) {
16
            return $provider->loadUserByApiKey($credentials);
17
        }
18
19
        return $provider->loadUserByUsername($credentials);
20
    }
21
}
22