]> Raphaƫl G. Git Repositories - userbundle/blob - Entity/Group.php
Fix variable name
[userbundle] / Entity / Group.php
1 <?php
2
3 // src/Rapsys/UserBundle/Entity/Group.php
4 namespace Rapsys\UserBundle\Entity;
5
6 class Group {
7 /**
8 * @var integer
9 */
10 protected $id;
11
12 /**
13 * @var string
14 */
15 protected $title;
16
17 /**
18 * @var \DateTime
19 */
20 protected $created;
21
22 /**
23 * @var \DateTime
24 */
25 protected $updated;
26
27 /**
28 * @var \Doctrine\Common\Collections\Collection
29 */
30 protected $users;
31
32 /**
33 * Constructor
34 *
35 * @param string $title The group name
36 */
37 public function __construct(string $title) {
38 $this->title = (string) $title;
39 $this->users = new \Doctrine\Common\Collections\ArrayCollection();
40 }
41
42 /**
43 * Get id
44 *
45 * @return integer
46 */
47 public function getId() {
48 return $this->id;
49 }
50
51 /**
52 * Set title
53 *
54 * @param string $title The group name
55 *
56 * @return User
57 */
58 public function setTitle($title) {
59 $this->title = $title;
60
61 return $this;
62 }
63
64 /**
65 * Get title
66 *
67 * @return string
68 */
69 public function getTitle() {
70 return $this->title;
71 }
72
73 /**
74 * Set created
75 *
76 * @param \DateTime $created
77 *
78 * @return User
79 */
80 public function setCreated($created) {
81 $this->created = $created;
82
83 return $this;
84 }
85
86 /**
87 * Get created
88 *
89 * @return \DateTime
90 */
91 public function getCreated() {
92 return $this->created;
93 }
94
95 /**
96 * Set updated
97 *
98 * @param \DateTime $updated
99 *
100 * @return User
101 */
102 public function setUpdated($updated) {
103 $this->updated = $updated;
104
105 return $this;
106 }
107
108 /**
109 * Get updated
110 *
111 * @return \DateTime
112 */
113 public function getUpdated() {
114 return $this->updated;
115 }
116
117 /**
118 * Add user
119 *
120 * @param \Rapsys\UserBundle\Entity\User $user
121 *
122 * @return Group
123 */
124 public function addUser(\Rapsys\UserBundle\Entity\User $user) {
125 $this->users[] = $user;
126
127 return $this;
128 }
129
130 /**
131 * Remove user
132 *
133 * @param \Rapsys\UserBundle\Entity\User $user
134 */
135 public function removeUser(\Rapsys\UserBundle\Entity\User $user) {
136 $this->users->removeElement($user);
137 }
138
139 /**
140 * Get users
141 *
142 * @return \Doctrine\Common\Collections\Collection
143 */
144 public function getUsers() {
145 return $this->users;
146 }
147
148 /**
149 * Returns a string representation of the group
150 *
151 * @return string
152 */
153 public function __toString(): string {
154 return $this->title;
155 }
156
157 /**
158 * Get role
159 *
160 * @return string
161 */
162 public function getRole() {
163 return 'ROLE_'.strtoupper($this->title);
164 }
165 }