Completed
Push — master ( 2e9ff7...454a32 )
by Alexis
07:25
created

User::setConfirmationToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace AWurth\SilexUser\Entity;
4
5
use AWurth\SilexUser\Model\User as BaseUser;
6
use DateTime;
7
use Doctrine\ORM\Mapping as ORM;
8
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
9
use Symfony\Component\Validator\Mapping\ClassMetadata;
10
11
/**
12
 * Base User entity class.
13
 *
14
 * @author Alexis Wurth <[email protected]>
15
 *
16
 * @ORM\MappedSuperclass
17
 */
18 View Code Duplication
abstract class User extends BaseUser
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
{
20
    /**
21
     * @var int
22
     *
23
     * @ORM\Id
24
     * @ORM\GeneratedValue
25
     * @ORM\Column(name="id", type="integer")
26
     */
27
    protected $id;
28
29
    /**
30
     * @var string
31
     *
32
     * @ORM\Column(name="username", type="string", length=180, unique=true)
33
     */
34
    protected $username;
35
36
    /**
37
     * @var string
38
     *
39
     * @ORM\Column(name="email", type="string", length=180, unique=true)
40
     */
41
    protected $email;
42
43
    /**
44
     * @var string
45
     *
46
     * @ORM\Column(name="password", type="string", length=255)
47
     */
48
    protected $password;
49
50
    /**
51
     * @var string
52
     *
53
     * @ORM\Column(name="salt", type="string", length=255, nullable=true)
54
     */
55
    protected $salt;
56
57
    /**
58
     * @var bool
59
     *
60
     * @ORM\Column(name="enabled", type="boolean")
61
     */
62
    protected $enabled = false;
63
64
    /**
65
     * @var DateTime
66
     *
67
     * @ORM\Column(name="last_login", type="datetime", nullable=true)
68
     */
69
    protected $lastLogin;
70
71
    /**
72
     * @var array
73
     *
74
     * @ORM\Column(name="roles", type="array")
75
     */
76
    protected $roles = [];
77
78
    /**
79
     * @var string
80
     *
81
     * @ORM\Column(name="confirmation_token", type="string", length=180, unique=true, nullable=true)
82
     */
83
    protected $confirmationToken;
84
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public static function loadValidatorMetadata(ClassMetadata $metadata)
89
    {
90
        $metadata->addConstraint(new UniqueEntity([
91
            'fields' => 'username',
92
            'message' => 'silex_user.username.already_used'
93
        ]));
94
        $metadata->addConstraint(new UniqueEntity([
95
            'fields' => 'email',
96
            'message' => 'silex_user.email.already_used'
97
        ]));
98
99
        parent::loadValidatorMetadata($metadata);
100
    }
101
}
102