Role::setPermissions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace WebCMS\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * Description of Role
9
 * @ORM\Entity
10
 * @author Tomáš Voslař <tomas.voslar at webcook.cz>
11
 */
12
class Role extends Entity
13
{
14
    /**
15
     * @ORM\Column(unique=true)
16
     * @var string
17
     */
18
    private $name;
19
20
    /**
21
     * @orm\ManyToMany(targetEntity="Permission", cascade={"persist"})
22
     * @orm\JoinColumn(name="permission_id", referencedColumnName="id", onDelete="CASCADE")
23
     */
24
    private $permissions;
25
26
    /**
27
     * @orm\Column(type="boolean")
28
     */
29
    private $automaticEnable;
30
31 45
    public function __construct()
32
    {
33 45
        $this->permissions = new \Doctrine\Common\Collections\ArrayCollection();
34 45
    }
35
36
    public function addPermission(Permission $permission)
37
    {
38
        if (!$this->getPermissions()->contains($permission)) {
39
            $this->permissions->add($permission);
40
        }
41
    }
42
43
    public function setPermissions($permissions)
44
    {
45
        $this->permissions = $permissions;
46
    }
47
48 42
    public function getName()
49
    {
50 42
        return $this->name;
51
    }
52
53
    /**
54
     * @param string $name
55
     */
56 45
    public function setName($name)
57
    {
58 45
        $this->name = $name;
59 45
    }
60
61 42
    public function getPermissions()
62
    {
63 42
        return $this->permissions;
64
    }
65
66
    public function getAutomaticEnable()
67
    {
68
        return $this->automaticEnable;
69
    }
70
71
    /**
72
     * @param boolean $automaticEnable
73
     */
74 45
    public function setAutomaticEnable($automaticEnable)
75
    {
76 45
        $this->automaticEnable = $automaticEnable;
77 45
    }
78
}
79