Completed
Pull Request — master (#78)
by
unknown
12:31
created

UserRole   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 90
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getId() 0 4 1
A getRole() 0 4 1
A onPrePersist() 0 5 1
A onPreUpdate() 0 4 1
A getCreatedOn() 0 4 1
A getEditedOn() 0 4 1
A __toString() 0 4 1
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
    /**
47
     * @param string $roleName
48
     */
49
    public function __construct(string $roleName)
50
    {
51
        parent::__construct($roleName);
52
53
        $this->roleName = $roleName;
54
    }
55
56
    /**
57
     * @return int
58
     */
59
    public function getId(): int
60
    {
61
        return $this->id;
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    public function getRole(): string
68
    {
69
        return $this->roleName;
70
    }
71
72
    /**
73
     * @ORM\PrePersist
74
     */
75
    public function onPrePersist(): void
76
    {
77
        $this->createdOn = new DateTime();
78
        $this->editedOn = new DateTime();
79
    }
80
81
    /**
82
     * @ORM\PreUpdate
83
     */
84
    public function onPreUpdate(): void
85
    {
86
        $this->editedOn = new DateTime();
87
    }
88
89
    public function getCreatedOn(): DateTime
90
    {
91
        return $this->createdOn;
92
    }
93
94
    public function getEditedOn(): DateTime
95
    {
96
        return $this->editedOn;
97
    }
98
99
    public function __toString(): string
100
    {
101
        return $this->roleName;
102
    }
103
}
104