User   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 0 Features 2
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 84
c 4
b 0
f 2
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getCreatedAt() 0 4 1
A getSecurityRelatedObjects() 0 4 1
A getRoleNamePart() 0 4 1
A __construct() 0 7 1
1
<?php
2
3
namespace Dominikzogg\EnergyCalculator\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Dominikzogg\EnergyCalculator\Voter\RelatedObjectInterface;
7
use Saxulum\UserProvider\Model\AbstractUser;
8
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
9
10
/**
11
 * @ORM\Entity(repositoryClass="Dominikzogg\EnergyCalculator\Repository\UserRepository")
12
 * @ORM\Table(
13
 *     name="sf_user",
14
 *     uniqueConstraints={
15
 *         @ORM\UniqueConstraint(name="username_idx", columns={"username"})
16
 *     }
17
 * )
18
 * @UniqueEntity("username")
19
 */
20
class User extends AbstractUser implements RelatedObjectInterface
21
{
22
    /**
23
     * @var string
24
     * @ORM\Column(name="id", type="string", length=24)
25
     * @ORM\Id
26
     * @ORM\GeneratedValue(strategy="NONE")
27
     */
28
    protected $id;
29
30
    /**
31
     * @var string $username
32
     * @ORM\Column(name="username", type="string")
33
     */
34
    protected $username;
35
36
    /**
37
     * @var string $password
38
     * @ORM\Column(name="password", type="string")
39
     */
40
    protected $password;
41
42
    /**
43
     * @var string $salt
44
     * @ORM\Column(name="salt", type="string")
45
     */
46
    protected $salt;
47
48
    /**
49
     * @var string $email
50
     * @ORM\Column(name="email", type="string")
51
     */
52
    protected $email;
53
54
    /**
55
     * @var array $roles
56
     * @ORM\Column(name="roles", type="json_array")
57
     */
58
    protected $roles;
59
60
    /**
61
     * @var boolean $enabled
62
     * @ORM\Column(name="enabled", type="boolean")
63
     */
64
    protected $enabled = false;
65
66
    /**
67
     * @var \DateTime
68
     * @ORM\Column(name="created_at", type="datetime", nullable=true)
69
     */
70
    protected $createdAt;
71
72
    public function __construct()
73
    {
74
        $this->id = new \MongoId();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \MongoId() of type object<MongoId> is incompatible with the declared type string of property $id.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
75
        $this->createdAt = new \DateTime();
76
77
        parent::__construct();
78
    }
79
80
    /**
81
     * @return \DateTime
82
     */
83
    public function getCreatedAt()
84
    {
85
        return $this->createdAt;
86
    }
87
88
    /**
89
     * @return array
90
     */
91
    public function getSecurityRelatedObjects()
92
    {
93
        return array($this);
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getRoleNamePart()
100
    {
101
        return 'user';
102
    }
103
}
104