Passed
Pull Request — develop (#166)
by Laurent
01:46
created

User   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 100
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 27
c 1
b 0
f 0
dl 0
loc 100
rs 10
wmc 12

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getUsername() 0 3 1
A getSalt() 0 3 1
A eraseCredentials() 0 2 1
A setUuid() 0 5 1
A getProfileInfos() 0 6 1
A getUuid() 0 3 1
A setEmail() 0 5 1
A getEmail() 0 3 1
A getPassword() 0 3 1
A getRoles() 0 7 2
A __construct() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the G.L.S.R. Apps package.
7
 *
8
 * (c) Dev-Int Création <[email protected]>.
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Core\Infrastructure\Persistence\DoctrineOrm\Entities;
15
16
use Doctrine\ORM\Mapping as ORM;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Symfony\Component\Security\Core\User\UserInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Security\Core\User\UserInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
19
/**
20
 * @ORM\Entity(repositoryClass="Administration\Infrastructure\Persistence\DoctrineOrm\Repositories\DoctrineUserRepository")
21
 * @ORM\Table(name="user")
22
 */
23
class User implements UserInterface
24
{
25
    /**
26
     * @ORM\Id
27
     * @ORM\Column(type="guid")
28
     * @ORM\GeneratedValue(strategy="NONE")
29
     */
30
    private string $uuid;
31
32
    /**
33
     * @ORM\Column(type="string", length=150, nullable=false)
34
     */
35
    private string $username;
36
37
    /**
38
     * @ORM\Column(type="string", length=255, nullable=false)
39
     */
40
    private string $email;
41
42
    /**
43
     * @ORM\Column(type="string", length=120, nullable=false)
44
     */
45
    private string $password;
46
47
    /**
48
     * @ORM\Column(type="array", nullable=false)
49
     */
50
    private array $roles;
51
52
    public function __construct(string $uuid, string $username, string $email, string $password, array $roles)
53
    {
54
        $this->uuid = $uuid;
55
        $this->username = $username;
56
        $this->email = $email;
57
        $this->password = $password;
58
        $this->roles = $roles;
59
    }
60
61
    public function getUuid(): string
62
    {
63
        return $this->uuid;
64
    }
65
66
    public function setUuid(string $uuid): self
67
    {
68
        $this->uuid = $uuid;
69
70
        return $this;
71
    }
72
73
    public function getEmail(): string
74
    {
75
        return $this->email;
76
    }
77
78
    public function setEmail(string $email): self
79
    {
80
        $this->email = $email;
81
82
        return $this;
83
    }
84
85
    public function getRoles(): array
86
    {
87
        if ([] === $this->roles) {
88
            $this->roles = ['ROLE_USER'];
89
        }
90
91
        return \array_unique($this->roles);
92
    }
93
94
    public function getPassword(): string
95
    {
96
        return $this->password;
97
    }
98
99
    public function getSalt(): ?string
100
    {
101
        return null;
102
    }
103
104
    public function getUsername(): string
105
    {
106
        return $this->username;
107
    }
108
109
    public function eraseCredentials(): void
110
    {
111
        // TODO: Implement eraseCredentials() method.
112
    }
113
114
    /**
115
     * @see AuthenticationSuccessResponseListener::onAuthenticationSuccessResponse
116
     */
117
    public function getProfileInfos(): array
118
    {
119
        return [
120
            'uuid' => $this->getUuid(),
121
            'username' => $this->getUsername(),
122
            'email' => $this->getEmail(),
123
        ];
124
    }
125
}
126