Role   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 7
c 3
b 0
f 0
lcom 1
cbo 1
dl 0
loc 102
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A setName() 0 6 1
A getName() 0 4 1
A __construct() 0 4 1
A addUser() 0 6 1
A removeUser() 0 4 1
A getUsers() 0 4 1
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
use Gedmo\Mapping\Annotation as Gedmo;
8
use Symfony\Component\Validator\Constraints as Assert;
9
10
/**
11
 * Role
12
 *
13
 * @ORM\Table(name="role")
14
 * @ORM\Entity(repositoryClass="AppBundle\Repository\RoleRepository")
15
 */
16
class Role
17
{
18
    /**
19
     * @var int
20
     *
21
     * @ORM\Column(name="id", type="integer")
22
     * @ORM\Id
23
     * @ORM\GeneratedValue(strategy="AUTO")
24
     */
25
    private $id;
26
27
    /**
28
     * @var string
29
     *
30
     * @ORM\Column(name="name", type="string", length=50)
31
     *
32
     * @Assert\NotBlank()
33
     * @Assert\Length(max = 50)
34
     */
35
    private $name;
36
37
    /**
38
     * @ORM\OneToMany(targetEntity="User", mappedBy="role")
39
     */
40
    private $users;
41
42
    /**
43
     * Get id
44
     *
45
     * @return int
46
     */
47
    public function getId()
48
    {
49
        return $this->id;
50
    }
51
52
    /**
53
     * Set name
54
     *
55
     * @param string $name
56
     *
57
     * @return Role
58
     */
59
    public function setName($name)
60
    {
61
        $this->name = $name;
62
63
        return $this;
64
    }
65
66
    /**
67
     * Get name
68
     *
69
     * @return string
70
     */
71
    public function getName()
72
    {
73
        return $this->name;
74
    }
75
76
    /**
77
     * Constructor
78
     */
79
    public function __construct()
80
    {
81
        $this->users = new ArrayCollection();
82
    }
83
84
    /**
85
     * Add user
86
     *
87
     * @param \AppBundle\Entity\User $user
88
     *
89
     * @return Role
90
     */
91
    public function addUser(User $user)
92
    {
93
        $this->users[] = $user;
94
95
        return $this;
96
    }
97
98
    /**
99
     * Remove user
100
     *
101
     * @param \AppBundle\Entity\User $user
102
     */
103
    public function removeUser(User $user)
104
    {
105
        $this->users->removeElement($user);
106
    }
107
108
    /**
109
     * Get users
110
     *
111
     * @return \Doctrine\Common\Collections\Collection
112
     */
113
    public function getUsers()
114
    {
115
        return $this->users;
116
    }
117
}
118