Role::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Del\Passport\Entity;
6
7
use Bone\BoneDoctrine\Traits\HasId;
8
use Del\Passport\RoleInterface;
9
use Doctrine\Common\Collections\ArrayCollection;
10
use Doctrine\Common\Collections\Collection;
11
use Doctrine\ORM\Mapping as ORM;
12
13
#[ORM\Entity]
14
#[ORM\UniqueConstraint(name: "roleName_idx", columns: ["roleName"])]
15
class Role implements RoleInterface
16
{
17
    use HasId;
18
19
    #[ORM\Column(type: 'string', length: 50)]
20
    private string $roleName = '';
21
22
    #[ORM\OneToMany(targetEntity: Role::class, mappedBy: 'parentRole')]
23
    private Collection $children;
24
25
    #[ORM\ManyToOne(targetEntity: Role::class, inversedBy: 'children')]
26
    private ?Role $parentRole;
27
28
    #[ORM\Column(type: 'string', length: 75)]
29
    private string $class = '';
30
31 4
    public function __construct()
32
    {
33 4
        $this->children = new ArrayCollection();
34
    }
35
36 2
    public function getId(): int
37
    {
38 2
        return $this->id;
39
    }
40
41 2
    public function getRoleName(): string
42
    {
43 2
        return $this->roleName;
44
    }
45
46 4
    public function setRoleName(string $roleName): void
47
    {
48 4
        $this->roleName = $roleName;
49
    }
50
51 1
    public function getChildren(): Collection
52
    {
53 1
        return $this->children;
54
    }
55
56 1
    public function setChildren(Collection $children): void
57
    {
58 1
        $this->children = $children;
59
    }
60
61 1
    public function getParentRole(): Role
62
    {
63 1
        return $this->parentRole;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->parentRole could return the type null which is incompatible with the type-hinted return Del\Passport\Entity\Role. Consider adding an additional type-check to rule them out.
Loading history...
64
    }
65
66 1
    public function setParentRole(Role $parentRole): void
67
    {
68 1
        $this->parentRole = $parentRole;
69
    }
70
71 2
    public function getClass(): string
72
    {
73 2
        return $this->class;
74
    }
75
76 3
    public function setClass(string $class): void
77
    {
78 3
        $this->class = $class;
79
    }
80
}
81
82