Organization::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/*
3
  ÁTICA - Aplicación web para la gestión documental de centros educativos
4
5
  Copyright (C) 2015-2017: Luis Ramón López López
6
7
  This program is free software: you can redistribute it and/or modify
8
  it under the terms of the GNU Affero General Public License as published by
9
  the Free Software Foundation, either version 3 of the License, or
10
  (at your option) any later version.
11
12
  This program is distributed in the hope that it will be useful,
13
  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  GNU Affero General Public License for more details.
16
17
  You should have received a copy of the GNU Affero General Public License
18
  along with this program.  If not, see [http://www.gnu.org/licenses/].
19
*/
20
21
namespace AppBundle\Entity;
22
23
use Doctrine\Common\Collections\Collection;
24
use Doctrine\ORM\Mapping as ORM;
25
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
26
use Symfony\Component\Validator\Constraints as Assert;
27
28
/**
29
 * @ORM\Entity(repositoryClass="AppBundle\Repository\OrganizationRepository")
30
 * @UniqueEntity("code")
31
 */
32
class Organization
33
{
34
    /**
35
     * @ORM\Id
36
     * @ORM\GeneratedValue(strategy="AUTO")
37
     * @ORM\Column(type="integer")
38
     * @var int
39
     */
40
    private $id;
41
42
    /**
43
     * @ORM\Column(type="string")
44
     * @var string
45
     */
46
    private $name;
47
48
    /**
49
     * @ORM\Column(type="string", unique=true)
50
     * @var string
51
     */
52
    private $code;
53
54
    /**
55
     * @ORM\Column(type="string", nullable=true)
56
     * @var string
57
     */
58
    private $address;
59
60
    /**
61
     * @ORM\Column(type="string")
62
     * @var string
63
     */
64
    private $city;
65
66
    /**
67
     * @ORM\Column(type="string", nullable=true)
68
     * @var string
69
     */
70
    private $zipCode;
71
72
    /**
73
     * @ORM\Column(type="string", nullable=true)
74
     * @var string
75
     */
76
    private $phoneNumber;
77
78
    /**
79
     * @ORM\Column(type="string", nullable=true)
80
     * @var string
81
     */
82
    private $faxNumber;
83
84
    /**
85
     * @ORM\Column(type="string", nullable=true)
86
     * @Assert\Email
87
     * @var string
88
     */
89
    private $emailAddress;
90
91
    /**
92
     * @ORM\Column(type="string", nullable=true)
93
     * @var string
94
     */
95
    private $webSite;
96
97
    /**
98
     * @ORM\Column(type="text", nullable=true)
99
     * @var string
100
     */
101
    private $description;
102
103
    /**
104
     * @ORM\OneToMany(targetEntity="Membership", mappedBy="organization")
105
     * @var Collection
106
     */
107
    private $memberships;
108
109
    /**
110
     * @ORM\ManyToMany(targetEntity="User", inversedBy="managedOrganizations")
111
     * @ORM\JoinTable(name="manager")
112
     * @var Collection
113
     */
114
    private $administrators;
115
116
    /**
117
     * @ORM\OneToOne(targetEntity="Element")
118
     * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
119
     */
120
    private $element;
121
122
    /**
123
     * Constructor
124
     */
125
    public function __construct()
126
    {
127
        $this->memberships = new \Doctrine\Common\Collections\ArrayCollection();
128
        $this->administrators = new \Doctrine\Common\Collections\ArrayCollection();
129
    }
130
131
    /**
132
     * Returns the organization name
133
     *
134
     * @return string
135
     */
136
    public function __toString()
137
    {
138
        return $this->getName();
139
    }
140
141
    /**
142
     * Get id
143
     *
144
     * @return integer
145
     */
146
    public function getId()
147
    {
148
        return $this->id;
149
    }
150
151
    /**
152
     * Set name
153
     *
154
     * @param string $name
155
     *
156
     * @return Organization
157
     */
158
    public function setName($name)
159
    {
160
        $this->name = $name;
161
162
        return $this;
163
    }
164
165
    /**
166
     * Get name
167
     *
168
     * @return string
169
     */
170
    public function getName()
171
    {
172
        return $this->name;
173
    }
174
175
    /**
176
     * Set code
177
     *
178
     * @param string $code
179
     *
180
     * @return Organization
181
     */
182
    public function setCode($code)
183
    {
184
        $this->code = $code;
185
186
        return $this;
187
    }
188
189
    /**
190
     * Get code
191
     *
192
     * @return string
193
     */
194
    public function getCode()
195
    {
196
        return $this->code;
197
    }
198
199
    /**
200
     * Set address
201
     *
202
     * @param string $address
203
     *
204
     * @return Organization
205
     */
206
    public function setAddress($address)
207
    {
208
        $this->address = $address;
209
210
        return $this;
211
    }
212
213
    /**
214
     * Get address
215
     *
216
     * @return string
217
     */
218
    public function getAddress()
219
    {
220
        return $this->address;
221
    }
222
223
    /**
224
     * Set city
225
     *
226
     * @param string $city
227
     *
228
     * @return Organization
229
     */
230
    public function setCity($city)
231
    {
232
        $this->city = $city;
233
234
        return $this;
235
    }
236
237
    /**
238
     * Get city
239
     *
240
     * @return string
241
     */
242
    public function getCity()
243
    {
244
        return $this->city;
245
    }
246
247
    /**
248
     * Set zipCode
249
     *
250
     * @param string $zipCode
251
     *
252
     * @return Organization
253
     */
254
    public function setZipCode($zipCode)
255
    {
256
        $this->zipCode = $zipCode;
257
258
        return $this;
259
    }
260
261
    /**
262
     * Get zipCode
263
     *
264
     * @return string
265
     */
266
    public function getZipCode()
267
    {
268
        return $this->zipCode;
269
    }
270
271
    /**
272
     * Set phoneNumber
273
     *
274
     * @param string $phoneNumber
275
     *
276
     * @return Organization
277
     */
278
    public function setPhoneNumber($phoneNumber)
279
    {
280
        $this->phoneNumber = $phoneNumber;
281
282
        return $this;
283
    }
284
285
    /**
286
     * Get phoneNumber
287
     *
288
     * @return string
289
     */
290
    public function getPhoneNumber()
291
    {
292
        return $this->phoneNumber;
293
    }
294
295
    /**
296
     * Set faxNumber
297
     *
298
     * @param string $faxNumber
299
     *
300
     * @return Organization
301
     */
302
    public function setFaxNumber($faxNumber)
303
    {
304
        $this->faxNumber = $faxNumber;
305
306
        return $this;
307
    }
308
309
    /**
310
     * Get faxNumber
311
     *
312
     * @return string
313
     */
314
    public function getFaxNumber()
315
    {
316
        return $this->faxNumber;
317
    }
318
319
    /**
320
     * Set emailAddress
321
     *
322
     * @param string $emailAddress
323
     *
324
     * @return Organization
325
     */
326
    public function setEmailAddress($emailAddress)
327
    {
328
        $this->emailAddress = $emailAddress;
329
330
        return $this;
331
    }
332
333
    /**
334
     * Get emailAddress
335
     *
336
     * @return string
337
     */
338
    public function getEmailAddress()
339
    {
340
        return $this->emailAddress;
341
    }
342
343
    /**
344
     * Set webSite
345
     *
346
     * @param string $webSite
347
     *
348
     * @return Organization
349
     */
350
    public function setWebSite($webSite)
351
    {
352
        $this->webSite = $webSite;
353
354
        return $this;
355
    }
356
357
    /**
358
     * Get webSite
359
     *
360
     * @return string
361
     */
362
    public function getWebSite()
363
    {
364
        return $this->webSite;
365
    }
366
367
    /**
368
     * Set description
369
     *
370
     * @param string $description
371
     *
372
     * @return Organization
373
     */
374
    public function setDescription($description)
375
    {
376
        $this->description = $description;
377
378
        return $this;
379
    }
380
381
    /**
382
     * Get description
383
     *
384
     * @return string
385
     */
386
    public function getDescription()
387
    {
388
        return $this->description;
389
    }
390
391
    /**
392
     * Add membership
393
     *
394
     * @param Membership $membership
395
     *
396
     * @return Organization
397
     */
398
    public function addMembership(Membership $membership)
399
    {
400
        $this->memberships[] = $membership;
401
402
        return $this;
403
    }
404
405
    /**
406
     * Remove membership
407
     *
408
     * @param Membership $membership
409
     */
410
    public function removeMembership(Membership $membership)
411
    {
412
        $this->memberships->removeElement($membership);
413
    }
414
415
    /**
416
     * Get memberships
417
     *
418
     * @return Collection
419
     */
420
    public function getMemberships()
421
    {
422
        return $this->memberships;
423
    }
424
425
    /**
426
     * Add administrator
427
     *
428
     * @param User $administrator
429
     *
430
     * @return Organization
431
     */
432
    public function addAdministrator(User $administrator)
433
    {
434
        if (!$this->administrators->contains($administrator)) {
435
            $this->administrators->add($administrator);
436
            $administrator->addManagedOrganization($this);
437
        }
438
439
        return $this;
440
    }
441
442
    /**
443
     * Remove administrator
444
     *
445
     * @param User $administrator
446
     */
447
    public function removeAdministrator(User $administrator)
448
    {
449
        if ($this->administrators->contains($administrator)) {
450
            $this->administrators->removeElement($administrator);
451
            $administrator->removeManagedOrganization($this);
452
        }
453
    }
454
455
    /**
456
     * Get administrators
457
     *
458
     * @return \Doctrine\Common\Collections\Collection
459
     */
460
    public function getAdministrators()
461
    {
462
        return $this->administrators;
463
    }
464
465
    /**
466
     * Set currentElement
467
     *
468
     * @param Element $element
469
     *
470
     * @return Organization
471
     */
472
    public function setElement(Element $element = null)
473
    {
474
        $this->element = $element;
475
476
        return $this;
477
    }
478
479
    /**
480
     * Get currentElement
481
     *
482
     * @return Element
483
     */
484
    public function getElement()
485
    {
486
        return $this->element;
487
    }
488
}
489