Test Failed
Branch master (fdda4e)
by ANTHONIUS
03:39
created

User::getEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/*
4
 * This file is part of the EOffice project.
5
 *
6
 * (c) Anthonius Munthi <https://itstoni.com>
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
declare(strict_types=1);
13
14
namespace EOffice\User\Model;
15
16
use EOffice\Contracts\User\Model\UserInterface;
17
18
/**
19
 * @psalm-suppress MixedReturnTypeCoercion
20
 * @psalm-suppress PropertyNotSetInConstructor
21
 */
22
class User implements UserInterface
23
{
24
    /**
25
     * @var string
26
     * @psalm-suppress PropertyNotSetInConstructor
27
     */
28
    protected string $id;
29
    protected string $username;
30
    protected string $email;
31
    protected string $password;
32
    protected ?string $salt = null;
33
    protected array $roles;
34
    protected bool $enabled          = true;
35
    protected ?string $plainPassword = null;
36
37
    /**
38
     * @param string      $username
39
     * @param string      $email
40
     * @param string|null $plainPassword
41
     * @param array       $roles
42
     * @param bool        $enabled
43
     */
44
    public function __construct(
45
        string $username,
46
        string $email,
47
        ?string $plainPassword = null,
48
        array $roles = [],
49
        bool $enabled = true
50
    ) {
51
        $this->username      = $username;
52
        $this->email         = $email;
53
        $this->plainPassword = $plainPassword;
54
        $this->roles         = $roles;
55
        $this->enabled       = $enabled;
56
    }
57
58
    /**
59
     * @return string[]
60
     */
61
    public function getRoles()
62
    {
63
        $roles   = $this->roles;
64
        $roles[] = 'ROLE_USER';
65
66
        return array_unique($roles);
67
    }
68
69
    public function getPassword(): string
70
    {
71
        return $this->password;
72
    }
73
74
    public function getSalt(): ?string
75
    {
76
        return $this->salt;
77
    }
78
79
    public function eraseCredentials(): void
80
    {
81
        // TODO: Implement eraseCredentials() method.
82
    }
83
84
    public function getPlainPassword(): ?string
85
    {
86
        return $this->plainPassword;
87
    }
88
89
    public function setPassword(string $password): void
90
    {
91
        $this->password = $password;
92
    }
93
94
    public function __call(string $name, array $arguments): string
95
    {
96
        // TODO: Implement @method string getUserIdentifier()
97
        return $this->id;
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function getId(): string
104
    {
105
        return $this->id;
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getUsername(): string
112
    {
113
        return $this->username;
114
    }
115
116
    /**
117
     * @return string
118
     */
119
    public function getEmail(): string
120
    {
121
        return $this->email;
122
    }
123
}
124