Failed Conditions
Push — master ( cccd95...989cb2 )
by Florent
03:57
created

UserProvider::refreshUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\SecurityBundle\Tests\TestBundle\Service;
15
16
use OAuth2Framework\SecurityBundle\Tests\TestBundle\Entity\User;
17
use OAuth2Framework\SecurityBundle\Tests\TestBundle\Entity\UserRepository;
18
use OAuth2Framework\Component\Core\UserAccount\UserAccountRepository;
19
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
20
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
21
use Symfony\Component\Security\Core\User\UserInterface;
22
use Symfony\Component\Security\Core\User\UserProviderInterface;
23
24
class UserProvider implements UserProviderInterface
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function loadUserByUsername($username)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
30
    {
31
        $user = $this->userRepository->findOneByUsername($username);
32
33
        if ($user) {
34
            return $user;
35
        }
36
37
        throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function refreshUser(UserInterface $user)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
44
    {
45
        return $this->loadUserByUsername($user->getUsername());
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function supportsClass($class)
52
    {
53
        return User::class === $class;
54
    }
55
}
56