Passed
Push — master ( 77d6c9...732152 )
by Florian
03:45
created

PasswordContainerProvider::refreshUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the feedback project.
5
 *
6
 * (c) Florian Moser <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace App\Security;
13
14
use App\Model\PasswordContainer;
15
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
16
use Symfony\Component\Security\Core\User\UserInterface;
17
use Symfony\Component\Security\Core\User\UserProviderInterface;
18
19
class PasswordContainerProvider implements UserProviderInterface
20
{
21
    /**
22
     * @var string
23
     */
24
    private $password;
25
26
    public function __construct(string $password)
27
    {
28
        $this->password = $password;
29
    }
30
31
    /**     *
32
     * @param UserInterface $user
33
     *
34
     * @return UserInterface
35
     */
36
    public function refreshUser(UserInterface $user)
37
    {
38
        return $user;
39
    }
40
41
    /**
42
     * Loads the user for the given username.
43
     *
44
     * This method must throw UsernameNotFoundException if the user is not
45
     * found.
46
     *
47
     * @param string $username The username
48
     *
49
     * @throws UsernameNotFoundException if the user is not found
50
     *
51
     * @return UserInterface
52
     */
53
    public function loadUserByUsername($username)
54
    {
55
        return new PasswordContainer($this->password);
56
    }
57
58
    /**
59
     * Whether this provider supports the given user class.
60
     *
61
     * @param string $class
62
     *
63
     * @return bool
64
     */
65
    public function supportsClass($class)
66
    {
67
        return PasswordContainer::class === $class;
68
    }
69
}
70