Completed
Push — master ( a42f17...ac8b9e )
by
unknown
12s
created

UserRole::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace SumoCoders\FrameworkMultiUserBundle\Entity;
4
5
use DateTime;
6
use Doctrine\ORM\Mapping as ORM;
7
use Symfony\Component\Security\Core\Role\Role;
8
9
/**
10
 * @ORM\Entity
11
 * @ORM\Table
12
 * @ORM\HasLifecycleCallbacks
13
 */
14
class UserRole extends Role
15
{
16
    /**
17
     * @var int
18
     *
19
     * @ORM\Id
20
     * @ORM\GeneratedValue(strategy="AUTO")
21
     * @ORM\Column(type="integer")
22
     */
23
    private $id;
24
25
    /**
26
     * @var string
27
     *
28
     * @ORM\Column(type="string")
29
     */
30
    private $roleName;
31
32
    /**
33
     * @var DateTime
34
     *
35
     * @ORM\Column(type="datetime")
36
     */
37
    private $createdOn;
38
39
    /**
40
     * @var DateTime
41
     *
42
     * @ORM\Column(type="datetime")
43
     */
44
    private $editedOn;
45
46
    public function __construct(string $roleName)
47
    {
48
        parent::__construct($roleName);
49
50
        $this->roleName = $roleName;
51
    }
52
53
    public function getId(): int
54
    {
55
        return $this->id;
56
    }
57
58
    public function getRole(): string
59
    {
60
        return $this->roleName;
61
    }
62
63
    public function getCreatedOn(): DateTime
64
    {
65
        return $this->createdOn;
66
    }
67
68
    public function getEditedOn(): DateTime
69
    {
70
        return $this->editedOn;
71
    }
72
73
    /**
74
     * @ORM\PrePersist
75
     */
76
    public function onPrePersist(): void
77
    {
78
        $this->createdOn = new DateTime();
79
        $this->editedOn = new DateTime();
80
    }
81
82
    /**
83
     * @ORM\PreUpdate
84
     */
85
    public function onPreUpdate(): void
86
    {
87
        $this->editedOn = new DateTime();
88
    }
89
90
    public function __toString(): string
91
    {
92
        return $this->roleName;
93
    }
94
}
95