]> Raphaël G. Git Repositories - airbundle/blob - Entity/Dance.php
Add strict
[airbundle] / Entity / Dance.php
1 <?php declare(strict_types=1);
2
3 /*
4 * this file is part of the rapsys packbundle package.
5 *
6 * (c) raphaël gertz <symfony@rapsys.eu>
7 *
8 * for the full copyright and license information, please view the license
9 * file that was distributed with this source code.
10 */
11
12 namespace Rapsys\AirBundle\Entity;
13
14 use Doctrine\Common\Collections\ArrayCollection;
15 use Doctrine\ORM\Event\PreUpdateEventArgs;
16
17 /**
18 * Dance
19 */
20 class Dance {
21 /**
22 * @var integer
23 */
24 private $id;
25
26 /**
27 * @var string
28 */
29 protected $title;
30
31 /**
32 * @var \DateTime
33 */
34 private $created;
35
36 /**
37 * @var \DateTime
38 */
39 private $updated;
40
41 /**
42 * @var ArrayCollection
43 */
44 private $applications;
45
46 /**
47 * @var ArrayCollection
48 */
49 private $users;
50
51 /**
52 * Constructor
53 */
54 public function __construct() {
55 //Set defaults
56 $this->created = new \DateTime('now');
57 $this->updated = new \DateTime('now');
58 $this->applications = new ArrayCollection();
59 $this->users = new ArrayCollection();
60 }
61
62 /**
63 * Get id
64 *
65 * @return integer
66 */
67 public function getId(): int {
68 return $this->id;
69 }
70
71 /**
72 * Set title
73 *
74 * @param string $title
75 *
76 * @return Dance
77 */
78 public function setTitle(string $title): Dance {
79 $this->title = $title;
80
81 return $this;
82 }
83
84 /**
85 * Get title
86 *
87 * @return string
88 */
89 public function getTitle(): string {
90 return $this->title;
91 }
92
93 /**
94 * Set created
95 *
96 * @param \DateTime $created
97 *
98 * @return Dance
99 */
100 public function setCreated(\DateTime $created): Dance {
101 $this->created = $created;
102
103 return $this;
104 }
105
106 /**
107 * Get created
108 *
109 * @return \DateTime
110 */
111 public function getCreated(): \DateTime {
112 return $this->created;
113 }
114
115 /**
116 * Set updated
117 *
118 * @param \DateTime $updated
119 *
120 * @return Dance
121 */
122 public function setUpdated(\DateTime $updated): Dance {
123 $this->updated = $updated;
124
125 return $this;
126 }
127
128 /**
129 * Get updated
130 *
131 * @return \DateTime
132 */
133 public function getUpdated(): \DateTime {
134 return $this->updated;
135 }
136
137 /**
138 * Add application
139 *
140 * @param Application $application
141 *
142 * @return Dance
143 */
144 public function addApplication(Application $application): Dance {
145 $this->applications[] = $application;
146
147 return $this;
148 }
149
150 /**
151 * Remove application
152 *
153 * @param Application $application
154 *
155 * @return bool
156 */
157 public function removeApplication(Application $application): bool {
158 return $this->applications->removeElement($application);
159 }
160
161 /**
162 * Get applications
163 *
164 * @return ArrayCollection
165 */
166 public function getApplications(): ArrayCollection {
167 return $this->applications;
168 }
169
170 /**
171 * Add user
172 *
173 * @param User $user
174 *
175 * @return Dance
176 */
177 public function addUser(User $user): Dance {
178 $this->users[] = $user;
179
180 return $this;
181 }
182
183 /**
184 * Remove user
185 *
186 * @param User $user
187 *
188 * @return bool
189 */
190 public function removeUser(User $user): bool {
191 return $this->users->removeElement($user);
192 }
193
194 /**
195 * Get users
196 *
197 * @return ArrayCollection
198 */
199 public function getUsers(): ArrayCollection {
200 return $this->users;
201 }
202
203 /**
204 * {@inheritdoc}
205 */
206 public function preUpdate(PreUpdateEventArgs $eventArgs) {
207 //Check that we have an session instance
208 if (($dance = $eventArgs->getEntity()) instanceof Dance) {
209 //Set updated value
210 $dance->setUpdated(new \DateTime('now'));
211 }
212 }
213
214 /**
215 * Returns a string representation of the slot
216 *
217 * @return string
218 */
219 public function __toString(): string {
220 return $this->title;
221 }
222 }