Passed
Push — develop ( fade15...748341 )
by
unknown
04:17
created

Roles::removeRole()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace AppBundle\Entity\Attribute\Accessor;
4
5
use AppBundle\Entity\Role;
6
7
/**
8
 * Trait Roles
9
 */
10
trait Roles
11
{
12
    /**
13
     * Add role
14
     *
15
     * @param \AppBundle\Entity\Role $role
16
     * @return object
17
     */
18
    public function addRole(Role $role)
19
    {
20
        if (!$this->roles->contains($role)) {
21
            $this->roles->add($role);
22
        }
23
24
        return $this;
25
    }
26
27
    /**
28
     * Remove roles
29
     *
30
     * @param \AppBundle\Entity\Role $role
31
     * @return object
32
     */
33
    public function removeRole(Role $role)
34
    {
35
        if ($this->roles->contains($role)) {
36
            $this->roles->removeElement($role);
37
        }
38
39
        return $this;
40
    }
41
42
    /**
43
     * Get roles
44
     *
45
     * @return array
46
     */
47
    public function getRoles()
48
    {
49
        return $this->roles->toArray();
50
    }
51
}
52