Passed
Branch 0.1 (d41d7c)
by Nils
02:15
created

Referee::getGames()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Torakel\DatabaseBundle\Entity;
3
4
use Doctrine\Common\Collections\ArrayCollection;
5
use Doctrine\ORM\Mapping as ORM;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
/**
8
 * @ORM\Entity
9
 * @ORM\HasLifecycleCallbacks
10
 * @ORM\Table(name="referee")
11
 */
12
class Referee
13
{
14
    /**
15
     * @var integer
16
     * @ORM\Column(type="integer")
17
     * @ORM\Id
18
     * @ORM\GeneratedValue(strategy="AUTO")
19
     */
20
    private $id;
21
22
    /**
23
     * @var string
24
     * @ORM\Column(type="string")
25
     */
26
    protected $slug;
27
28
    /**
29
     * @var string
30
     * @ORM\Column(type="string")
31
     */
32
    protected $firstname;
33
34
    /**
35
     * @var string
36
     * @ORM\Column(type="string")
37
     */
38
    protected $lastname;
39
40
    /**
41
     * @var string
42
     * @ORM\Column(type="string")
43
     */
44
    protected $title;
45
46
    /**
47
     * @var string
48
     * @ORM\Column(type="string", nullable=true)
49
     */
50
    protected $nickname;
51
52
    /**
53
     * @var \Torakel\DatabaseBundle\Entity\City
54
     * @ORM\ManyToOne(targetEntity="\Torakel\DatabaseBundle\Entity\City", inversedBy="referees")
55
     * @ORM\JoinColumn(name="city_id", referencedColumnName="id")
56
     */
57
    protected $city;
58
59
    /**
60
     * @var \Torakel\DatabaseBundle\Entity\Country
61
     * @ORM\ManyToOne(targetEntity="\Torakel\DatabaseBundle\Entity\Country", inversedBy="referees")
62
     * @ORM\JoinColumn(name="nationality_id", referencedColumnName="id")
63
     */
64
    protected $nationality;
65
66
    /**
67
     * @var string
68
     * @ORM\Column(type="text", nullable=true)
69
     */
70
    protected $altNames;
71
72
    /**
73
     * @var \Doctrine\Common\Collections\ArrayCollection;
74
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\Game", mappedBy="referee")
75
     */
76
    protected $games;
77
78
    /**
79
     * @var \DateTime
80
     * @ORM\Column(type="datetime", name="created_at")
81
     */
82
    protected $createdAt;
83
84
    /**
85
     * @var \DateTime
86
     * @ORM\Column(type="datetime", name="updated_at", nullable=true)
87
     */
88
    protected $updatedAt;
89
90
    /**
91
     * Constructor
92
     */
93 5
    public function __construct()
94
    {
95 5
        $this->games = new \Doctrine\Common\Collections\ArrayCollection();
96 5
    }
97
98
    /**
99
     * Add alt(ernative) name
100
     *
101
     * Adds an alternative name to the entity. For example external IDs.
102
     *
103
     * @param $name
104
     */
105 1
    public function addAltName($name)
106
    {
107 1
        $names = $this->getAltNames();
108 1
        if (in_array($name, $names) === false) {
109 1
            $names[] = $name;
110 1
            $this->setAltNames($names);
111
        }
112 1
    }
113
114 1
    public function getFullname()
115
    {
116 1
        if (!$this->firstname) {
117
118 1
            return $this->lastname;
119
        }
120 1
        $title = '';
121 1
        if ($this->title) {
122 1
            $title = $this->title . ' ';
123
        }
124 1
        $fullname = $title . $this->firstname . ' ' . $this->lastname;
125
126 1
        return $fullname;
127
    }
128
129
    /**
130
     * Get id
131
     *
132
     * @return integer
133
     */
134 1
    public function getId()
135
    {
136 1
        return $this->id;
137
    }
138
139
    /**
140
     * Set slug
141
     *
142
     * @param string $slug
143
     *
144
     * @return Referee
145
     */
146 1
    public function setSlug($slug)
147
    {
148 1
        $this->slug = $slug;
149
150 1
        return $this;
151
    }
152
153
    /**
154
     * Get slug
155
     *
156
     * @return string
157
     */
158 1
    public function getSlug()
159
    {
160 1
        return $this->slug;
161
    }
162
163
    /**
164
     * Set firstname
165
     *
166
     * @param string $firstname
167
     *
168
     * @return Referee
169
     */
170 1
    public function setFirstname($firstname)
171
    {
172 1
        $this->firstname = $firstname;
173
174 1
        return $this;
175
    }
176
177
    /**
178
     * Get firstname
179
     *
180
     * @return string
181
     */
182 1
    public function getFirstname()
183
    {
184 1
        return $this->firstname;
185
    }
186
187
    /**
188
     * Set lastname
189
     *
190
     * @param string $lastname
191
     *
192
     * @return Referee
193
     */
194 1
    public function setLastname($lastname)
195
    {
196 1
        $this->lastname = $lastname;
197
198 1
        return $this;
199
    }
200
201
    /**
202
     * Get lastname
203
     *
204
     * @return string
205
     */
206 1
    public function getLastname()
207
    {
208 1
        return $this->lastname;
209
    }
210
211
    /**
212
     * Set nickname
213
     *
214
     * @param string $nickname
215
     *
216
     * @return Referee
217
     */
218 1
    public function setNickname($nickname)
219
    {
220 1
        $this->nickname = $nickname;
221
222 1
        return $this;
223
    }
224
225
    /**
226
     * Get nickname
227
     *
228
     * @return string
229
     */
230 1
    public function getNickname()
231
    {
232 1
        return $this->nickname;
233
    }
234
235
    /**
236
     * Set altNames
237
     *
238
     * @param array $altNames
239
     *
240
     * @return Player
241
     */
242 1
    public function setAltNames($altNames)
243
    {
244 1
        $this->altNames = implode('|', $altNames);
245
246 1
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Torakel\DatabaseBundle\Entity\Referee which is incompatible with the documented return type Torakel\DatabaseBundle\Entity\Player.
Loading history...
247
    }
248
249
    /**
250
     * Get altNames
251
     *
252
     * @return array
253
     */
254 1
    public function getAltNames()
255
    {
256 1
        return explode('|', $this->altNames);
257
    }
258
259
    /**
260
     * Add game
261
     *
262
     * @param \Torakel\DatabaseBundle\Entity\Game $game
263
     *
264
     * @return Referee
265
     */
266 1
    public function addGame(\Torakel\DatabaseBundle\Entity\Game $game)
267
    {
268 1
        $this->games[] = $game;
269
270 1
        return $this;
271
    }
272
273
    /**
274
     * Remove game
275
     *
276
     * @param \Torakel\DatabaseBundle\Entity\Game $game
277
     */
278 1
    public function removeGame(\Torakel\DatabaseBundle\Entity\Game $game)
279
    {
280 1
        $this->games->removeElement($game);
281 1
    }
282
283
    /**
284
     * Get games
285
     *
286
     * @return \Doctrine\Common\Collections\Collection
287
     */
288 1
    public function getGames()
289
    {
290 1
        return $this->games;
291
    }
292
293
    /**
294
     * Set createdAt
295
     *
296
     * @param \DateTime $createdAt
297
     *
298
     * @return Referee
299
     */
300 1
    public function setCreatedAt($createdAt)
301
    {
302 1
        $this->createdAt = $createdAt;
303
304 1
        return $this;
305
    }
306
307
    /**
308
     * Get createdAt
309
     *
310
     * @return \DateTime
311
     */
312 1
    public function getCreatedAt()
313
    {
314 1
        return $this->createdAt;
315
    }
316
317
    /**
318
     * Set updatedAt
319
     *
320
     * @param \DateTime $updatedAt
321
     *
322
     * @return Referee
323
     */
324 1
    public function setUpdatedAt($updatedAt)
325
    {
326 1
        $this->updatedAt = $updatedAt;
327
328 1
        return $this;
329
    }
330
331
    /**
332
     * Get updatedAt
333
     *
334
     * @return \DateTime
335
     */
336 1
    public function getUpdatedAt()
337
    {
338 1
        return $this->updatedAt;
339
    }
340
341
    /**
342
     * @ORM\PrePersist
343
     */
344 1
    public function prePersist()
345
    {
346 1
        $this->createdAt = new \DateTime();
347 1
        $altNames = $this->getAltNames();
348 1
        $altNames[999999] = '';
349 1
        $this->setAltNames($altNames);
350 1
    }
351
352
    /**
353
     * @ORM\PreUpdate
354
     */
355 1
    public function preUpdate()
356
    {
357 1
        $this->updatedAt = new \DateTime();
358 1
    }
359
360
    /**
361
     * Set city
362
     *
363
     * @param \Torakel\DatabaseBundle\Entity\City $city
364
     *
365
     * @return Referee
366
     */
367 1
    public function setCity(\Torakel\DatabaseBundle\Entity\City $city = null)
368
    {
369 1
        $this->city = $city;
370
371 1
        return $this;
372
    }
373
374
    /**
375
     * Get city
376
     *
377
     * @return \Torakel\DatabaseBundle\Entity\City
378
     */
379 1
    public function getCity()
380
    {
381 1
        return $this->city;
382
    }
383
384
    /**
385
     * Set nationality
386
     *
387
     * @param \Torakel\DatabaseBundle\Entity\Country $nationality
388
     *
389
     * @return Referee
390
     */
391 1
    public function setNationality(\Torakel\DatabaseBundle\Entity\Country $nationality = null)
392
    {
393 1
        $this->nationality = $nationality;
394
395 1
        return $this;
396
    }
397
398
    /**
399
     * Get nationality
400
     *
401
     * @return \Torakel\DatabaseBundle\Entity\Country
402
     */
403 1
    public function getNationality()
404
    {
405 1
        return $this->nationality;
406
    }
407
408
    /**
409
     * Set title
410
     *
411
     * @param string $title
412
     *
413
     * @return Referee
414
     */
415 1
    public function setTitle($title)
416
    {
417 1
        $this->title = $title;
418
419 1
        return $this;
420
    }
421
422
    /**
423
     * Get title
424
     *
425
     * @return string
426
     */
427 1
    public function getTitle()
428
    {
429 1
        return $this->title;
430
    }
431
}
432