Passed
Push — master ( fb1eb0...02cee8 )
by Guido
08:09
created

UserRoleAction::getActionName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Gvera\Models;
3
4
use Doctrine\Common\Collections\ArrayCollection;
5
6
/**
7
* @Entity @Table(name="user_role_actions")
8
*/
9
class UserRoleAction
10
{
11
12
    /** @Id @Column(type="integer") @GeneratedValue */
13
    protected $id;
14
15
    /** @Column(type="string", nullable=false, unique=true, length=32) */
16
    protected $name;
17
18
    /**
19
     * Many Users have Many Stores.
20
     * @ManyToMany(targetEntity="UserRole", inversedBy="user_roles", fetch="EAGER", cascade={"persist"})
21
     */
22
    protected $userRoles;
23
24
    /**
25
     * UserRoleAction constructor.
26
     */
27
    public function __construct()
28
    {
29
        $this->userRoles = new ArrayCollection();
30
    }
31
32
    /**
33
     * @return mixed
34
     */
35
    public function getId()
36
    {
37
        return $this->id;
38
    }
39
40
    /**
41
     * @return mixed
42
     */
43
    public function getActionName()
44
    {
45
        return $this->name;
46
    }
47
48
    /**
49
     * @param $name
50
     */
51
    public function setActionName($name): void
52
    {
53
        $this->name = $name;
54
    }
55
56
    /**
57
     * @return mixed
58
     */
59
    public function getUserRoles()
60
    {
61
        return $this->userRoles;
62
    }
63
64
    /**
65
     * @param mixed $userRoles
66
     */
67
    public function setUserRoles($userRoles): void
68
    {
69
        $this->userRoles = $userRoles;
70
    }
71
72
    public function addUserRole(UserRole $role)
73
    {
74
        if (null === $role) {
75
            return;
76
        }
77
78
        $role->addRoleAction($this);
79
        if ($this->userRoles->contains($role)) {
80
            return;
81
        }
82
        $this->userRoles->add($role);
83
    }
84
85
    public function removeUserRole(UserRole $role)
86
    {
87
        if (!$this->userRoles->contains($role)) {
88
            return;
89
        }
90
        $this->userRoles->removeElement($role);
91
    }
92
}
93