Completed
Push — master ( 22af80...72b000 )
by Derek Stephen
09:26
created

Role::getParentRole()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace Del\Passport\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
8
/**
9
 * @ORM\Entity(repositoryClass="Del\Passport\Repository\RoleRepository")
10
 * @ORM\Table(name="PassportRole",uniqueConstraints={@ORM\UniqueConstraint(name="roleName_idx", columns={"roleName"})})
11
 * @ORM\InheritanceType("SINGLE_TABLE")
12
 * @ORM\DiscriminatorColumn(name="class", type="string")
13
 */
14
class Role implements PassportInterface
15
{
16
    /**
17
     * @ORM\Id
18
     * @ORM\Column(type="integer")
19
     * @ORM\GeneratedValue
20
     * @var int $id
21
     */
22
    private $id;
23
24
    /**
25
     * @ORM\Column(type="string",length=50)
26
     * @var string $roleName
27
     */
28
    private $roleName;
29
30
    /**
31
     * A role can have various roles under it
32
     * @OneToMany(targetEntity="Role", mappedBy="parentRole")
33
     * @var ArrayCollection $children
34
     */
35
    private $children;
36
37
    /**
38
     * Many role have one parent
39
     * @ManyToOne(targetEntity="Role", inversedBy="children")
40
     * @JoinColumn(name="parent_id", referencedColumnName="id")
41
     * @var Role $parentRole
42
     */
43
    private $parentRole;
44
45
    /**
46
     * @return int
47
     */
48
    public function getId(): int
49
    {
50
        return $this->id;
51
    }
52
53
    /**
54
     * @param int $id
55
     */
56
    public function setId(int $id): void
57
    {
58
        $this->id = $id;
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function getRoleName(): string
65
    {
66
        return $this->roleName;
67
    }
68
69
    /**
70
     * @param string $roleName
71
     */
72
    public function setRoleName(string $roleName): void
73
    {
74
        $this->roleName = $roleName;
75
    }
76
77
    /**
78
     * @return ArrayCollection
79
     */
80
    public function getChildren(): ArrayCollection
81
    {
82
        return $this->children;
83
    }
84
85
    /**
86
     * @param ArrayCollection $children
87
     */
88
    public function setChildren(ArrayCollection $children): void
89
    {
90
        $this->children = $children;
91
    }
92
93
    /**
94
     * @return Role
95
     */
96
    public function getParentRole(): Role
97
    {
98
        return $this->parentRole;
99
    }
100
101
    /**
102
     * @param Role $parentRole
103
     */
104
    public function setParentRole(Role $parentRole): void
105
    {
106
        $this->parentRole = $parentRole;
107
    }
108
}
109
110