User   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 10
c 1
b 0
f 1
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A eraseCredentials() 0 1 1
A __construct() 0 4 1
A getUserIdentifier() 0 2 1
1
<?php
2
3
/*
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2023 WEBEWEB
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 WBW\Bundle\CoreBundle\Model;
13
14
use Symfony\Component\Security\Core\User\UserInterface;
15
use WBW\Library\Traits\Integers\IntegerIdTrait;
16
use WBW\Library\Traits\Strings\ArrayRolesTrait;
17
use WBW\Library\Traits\Strings\StringPasswordTrait;
18
use WBW\Library\Traits\Strings\StringSaltTrait;
19
use WBW\Library\Traits\Strings\StringUsernameTrait;
20
21
/**
22
 * User.
23
 *
24
 * @author webeweb <https://github.com/webeweb>
25
 * @package WBW\Bundle\CoreBundle\Model
26
 */
27
class User implements UserInterface {
28
29
    use ArrayRolesTrait;
30
    use IntegerIdTrait;
31
    use StringSaltTrait;
32
    use StringPasswordTrait;
33
    use StringUsernameTrait;
34
35
    /**
36
     * Constructor.
37
     *
38
     * @param string|null $username The username.
39
     * @param string|null $password The password.
40
     * @param array $roles The roles.
41
     */
42
    public function __construct(?string $username = null, ?string $password = null, array $roles = []) {
43
        $this->setPassword($password);
44
        $this->setRoles($roles);
45
        $this->setUsername($username);
46
    }
47
48
    /**
49
     * {@inheritDoc}
50
     */
51
    public function eraseCredentials(): void {
52
        // NOTHING TO DO
53
    }
54
55
    /**
56
     * {@inheritDoc}
57
     */
58
    public function getUserIdentifier(): string {
59
        return $this->username;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->username could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
60
    }
61
}
62