Completed
Push — master ( dff1c0...97cc57 )
by Nils
02:23
created

Player::addGamePlayerStatistic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 1
cp 0
crap 2
rs 9.4285
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="player")
11
 */
12
class Player
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", nullable=true)
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", nullable=true)
43
     */
44
    protected $nickname;
45
46
    /**
47
     * @var string
48
     * @ORM\Column(type="text", nullable=true)
49
     */
50
    protected $altNames;
51
52
    /**
53
     * @var \Doctrine\Common\Collections\ArrayCollection;
54
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\Goal", mappedBy="player")
55
     */
56
    protected $goals;
57
58
    /**
59
     * @var \Doctrine\Common\Collections\ArrayCollection;
60
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\Goal", mappedBy="assistPlayer")
61
     */
62
    protected $assists;
63
64
    /**
65
     * @var \Doctrine\Common\Collections\ArrayCollection;
66
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\Card", mappedBy="player")
67
     */
68
    protected $cards;
69
70
    /**
71
     * @var \Doctrine\Common\Collections\ArrayCollection;
72
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\GamePlayer", mappedBy="player")
73
     */
74
    protected $gamePlayers;
75
76
    /**
77
     * @var \Doctrine\Common\Collections\ArrayCollection;
78
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\GamePlayerStatistic", mappedBy="player")
79
     */
80
    protected $gamePlayerStatistics;
81
82
    /**
83
     * @var \Doctrine\Common\Collections\ArrayCollection;
84
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\Substitution", mappedBy="intoPlayer")
85
     */
86
    protected $intoSubstitutions;
87
88
    /**
89
     * @var \Doctrine\Common\Collections\ArrayCollection;
90
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\Substitution", mappedBy="outPlayer")
91
     */
92
    protected $outSubstitutions;
93
94
    /**
95
     * @var \Torakel\DatabaseBundle\Entity\Country
96
     * @ORM\ManyToOne(targetEntity="\Torakel\DatabaseBundle\Entity\Country", inversedBy="coaches")
97
     * @ORM\JoinColumn(name="country_id", referencedColumnName="id")
98
     */
99
    protected $nationality;
100
101
    /**
102
     * @var \DateTime
103
     * @ORM\Column(type="datetime", name="created_at")
104
     */
105
    protected $createdAt;
106
107
    /**
108
     * @var \DateTime
109 2
     * @ORM\Column(type="datetime", name="updated_at", nullable=true)
110
     */
111 2
    protected $updatedAt;
112 2
113 2
    /**
114 2
     * Constructor
115 2
     */
116 2
    public function __construct()
117 2
    {
118
        $this->goals = new \Doctrine\Common\Collections\ArrayCollection();
119
        $this->cards = new \Doctrine\Common\Collections\ArrayCollection();
120
        $this->assists = new \Doctrine\Common\Collections\ArrayCollection();
121
        $this->gamePlayers = new \Doctrine\Common\Collections\ArrayCollection();
122
        $this->gamePlayerStatistics = new \Doctrine\Common\Collections\ArrayCollection();
123
        $this->intoSubstitutions = new \Doctrine\Common\Collections\ArrayCollection();
124
        $this->outSubstitutions = new \Doctrine\Common\Collections\ArrayCollection();
125
    }
126
127
    public function getFullname()
128
    {
129
        if (!$this->firstname) {
130
131
            return $this->lastname;
132
        }
133
        $fullname = $this->firstname . ' ' . $this->lastname;
134
135
        return $fullname;
136
    }
137
    /**
138
     * Add alt(ernative) name
139
     *
140
     * Adds an alternative name to the entity. For example external IDs.
141
     *
142
     * @param $name
143
     */
144
    public function addAltName($name)
145
    {
146
        $names = $this->getAltNames();
147
        if (in_array($name, $names) === false) {
148
            $names[] = $name;
149
            $this->setAltNames($names);
150
        }
151
    }
152
153
154
    /**
155
     * Get id
156
     *
157
     * @return integer
158
     */
159
    public function getId()
160
    {
161
        return $this->id;
162
    }
163
164
    /**
165
     * Set slug
166
     *
167
     * @param string $slug
168
     *
169
     * @return Player
170
     */
171
    public function setSlug($slug)
172
    {
173
        $this->slug = $slug;
174
175
        return $this;
176
    }
177
178
    /**
179
     * Get slug
180
     *
181
     * @return string
182
     */
183
    public function getSlug()
184
    {
185
        return $this->slug;
186
    }
187
188
    /**
189
     * Set firstname
190
     *
191
     * @param string $firstname
192
     *
193
     * @return Player
194
     */
195
    public function setFirstname($firstname)
196
    {
197
        $this->firstname = $firstname;
198
199
        return $this;
200
    }
201
202
    /**
203
     * Get firstname
204
     *
205
     * @return string
206
     */
207
    public function getFirstname()
208
    {
209
        return $this->firstname;
210
    }
211
212
    /**
213
     * Set nickname
214
     *
215
     * @param string $nickname
216
     *
217
     * @return Player
218
     */
219
    public function setNickname($nickname)
220
    {
221
        $this->nickname = $nickname;
222
223
        return $this;
224
    }
225
226
    /**
227
     * Get nickname
228
     *
229
     * @return string
230
     */
231
    public function getNickname()
232
    {
233
        return $this->nickname;
234
    }
235
236
    /**
237
     * Set altNames
238
     *
239
     * @param array $altNames
240
     *
241
     * @return Player
242
     */
243
    public function setAltNames($altNames)
244
    {
245
        $this->altNames = implode('|', $altNames);
246
247
        return $this;
248
    }
249
250
    /**
251
     * Get altNames
252
     *
253
     * @return array
254
     */
255
    public function getAltNames()
256
    {
257
        return explode('|', $this->altNames);
258
    }
259
260
    /**
261
     * Add goal
262
     *
263
     * @param \Torakel\DatabaseBundle\Entity\Goal $goal
264
     *
265
     * @return Player
266
     */
267
    public function addGoal(\Torakel\DatabaseBundle\Entity\Goal $goal)
268
    {
269
        $this->goals[] = $goal;
270
271
        return $this;
272
    }
273
274
    /**
275
     * Remove goal
276
     *
277
     * @param \Torakel\DatabaseBundle\Entity\Goal $goal
278
     */
279
    public function removeGoal(\Torakel\DatabaseBundle\Entity\Goal $goal)
280
    {
281
        $this->goals->removeElement($goal);
282
    }
283
284
    /**
285
     * Get goals
286
     *
287
     * @return \Doctrine\Common\Collections\Collection
288
     */
289
    public function getGoals()
290
    {
291
        return $this->goals;
292
    }
293
294
    /**
295
     * Add card
296
     *
297
     * @param \Torakel\DatabaseBundle\Entity\Card $card
298
     *
299
     * @return Player
300
     */
301
    public function addCard(\Torakel\DatabaseBundle\Entity\Card $card)
302
    {
303
        $this->cards[] = $card;
304
305
        return $this;
306
    }
307
308
    /**
309
     * Remove card
310
     *
311
     * @param \Torakel\DatabaseBundle\Entity\Card $card
312
     */
313
    public function removeCard(\Torakel\DatabaseBundle\Entity\Card $card)
314
    {
315
        $this->cards->removeElement($card);
316
    }
317
318
    /**
319
     * Get cards
320
     *
321
     * @return \Doctrine\Common\Collections\Collection
322
     */
323
    public function getCards()
324
    {
325
        return $this->cards;
326
    }
327
328
    /**
329
     * Add assist
330
     *
331
     * @param \Torakel\DatabaseBundle\Entity\Goal $assist
332
     *
333
     * @return Player
334
     */
335
    public function addAssist(\Torakel\DatabaseBundle\Entity\Goal $assist)
336
    {
337
        $this->assists[] = $assist;
338
339
        return $this;
340
    }
341
342
    /**
343
     * Remove assist
344
     *
345
     * @param \Torakel\DatabaseBundle\Entity\Goal $assist
346
     */
347
    public function removeAssist(\Torakel\DatabaseBundle\Entity\Goal $assist)
348
    {
349
        $this->assists->removeElement($assist);
350
    }
351
352
    /**
353
     * Get assists
354
     *
355
     * @return \Doctrine\Common\Collections\Collection
356
     */
357
    public function getAssists()
358
    {
359
        return $this->assists;
360
    }
361
362
    /**
363
     * Add gamePlayer
364
     *
365
     * @param \Torakel\DatabaseBundle\Entity\GamePlayer $gamePlayer
366
     *
367
     * @return Player
368
     */
369
    public function addGamePlayer(\Torakel\DatabaseBundle\Entity\GamePlayer $gamePlayer)
370
    {
371
        $this->gamePlayers[] = $gamePlayer;
372
373
        return $this;
374
    }
375
376
    /**
377
     * Remove gamePlayer
378
     *
379
     * @param \Torakel\DatabaseBundle\Entity\GamePlayer $gamePlayer
380
     */
381
    public function removeGamePlayer(\Torakel\DatabaseBundle\Entity\GamePlayer $gamePlayer)
382
    {
383
        $this->gamePlayers->removeElement($gamePlayer);
384
    }
385
386
    /**
387
     * Get gamePlayers
388
     *
389
     * @return \Doctrine\Common\Collections\Collection
390
     */
391
    public function getGamePlayers()
392
    {
393
        return $this->gamePlayers;
394
    }
395
396
    /**
397
     * Add intoSubstitution
398
     *
399
     * @param \Torakel\DatabaseBundle\Entity\Substitution $intoSubstitution
400
     *
401
     * @return Player
402
     */
403
    public function addIntoSubstitution(\Torakel\DatabaseBundle\Entity\Substitution $intoSubstitution)
404
    {
405
        $this->intoSubstitutions[] = $intoSubstitution;
406
407
        return $this;
408
    }
409
410
    /**
411
     * Remove intoSubstitution
412
     *
413
     * @param \Torakel\DatabaseBundle\Entity\Substitution $intoSubstitution
414
     */
415
    public function removeIntoSubstitution(\Torakel\DatabaseBundle\Entity\Substitution $intoSubstitution)
416
    {
417
        $this->intoSubstitutions->removeElement($intoSubstitution);
418
    }
419
420
    /**
421
     * Get intoSubstitutions
422
     *
423
     * @return \Doctrine\Common\Collections\Collection
424
     */
425
    public function getIntoSubstitutions()
426
    {
427
        return $this->intoSubstitutions;
428
    }
429
430
    /**
431
     * Add outSubstitution
432
     *
433
     * @param \Torakel\DatabaseBundle\Entity\Substitution $outSubstitution
434
     *
435
     * @return Player
436
     */
437
    public function addOutSubstitution(\Torakel\DatabaseBundle\Entity\Substitution $outSubstitution)
438
    {
439
        $this->outSubstitutions[] = $outSubstitution;
440
441
        return $this;
442
    }
443
444
    /**
445
     * Remove outSubstitution
446
     *
447
     * @param \Torakel\DatabaseBundle\Entity\Substitution $outSubstitution
448
     */
449
    public function removeOutSubstitution(\Torakel\DatabaseBundle\Entity\Substitution $outSubstitution)
450
    {
451
        $this->outSubstitutions->removeElement($outSubstitution);
452
    }
453
454
    /**
455
     * Get outSubstitutions
456
     *
457
     * @return \Doctrine\Common\Collections\Collection
458
     */
459
    public function getOutSubstitutions()
460
    {
461
        return $this->outSubstitutions;
462
    }
463
464
    /**
465
     * Set createdAt
466
     *
467
     * @param \DateTime $createdAt
468
     *
469
     * @return Player
470
     */
471
    public function setCreatedAt($createdAt)
472
    {
473
        $this->createdAt = $createdAt;
474
475
        return $this;
476
    }
477
478
    /**
479
     * Get createdAt
480
     *
481
     * @return \DateTime
482
     */
483
    public function getCreatedAt()
484
    {
485
        return $this->createdAt;
486
    }
487
488
    /**
489
     * Set updatedAt
490
     *
491
     * @param \DateTime $updatedAt
492
     *
493
     * @return Player
494
     */
495
    public function setUpdatedAt($updatedAt)
496
    {
497
        $this->updatedAt = $updatedAt;
498
499
        return $this;
500
    }
501
502
    /**
503
     * Get updatedAt
504
     *
505
     * @return \DateTime
506
     */
507
    public function getUpdatedAt()
508
    {
509
        return $this->updatedAt;
510
    }
511
512
    /**
513
     * @ORM\PrePersist
514
     */
515
    public function prePersist()
516
    {
517
        $this->createdAt = new \DateTime();
518
        $altNames = $this->getAltNames();
519
        $altNames[999999] = '';
520
        $this->setAltNames($altNames);
521
    }
522
523
    /**
524
     * @ORM\PreUpdate
525
     */
526
    public function preUpdate()
527
    {
528
        $this->updatedAt = new \DateTime();
529
    }
530
531
    /**
532
     * Set lastname
533
     *
534
     * @param string $lastname
535
     *
536
     * @return Player
537
     */
538
    public function setLastname($lastname)
539
    {
540
        $this->lastname = $lastname;
541
542
        return $this;
543
    }
544
545
    /**
546
     * Get lastname
547
     *
548
     * @return string
549
     */
550
    public function getLastname()
551
    {
552
        return $this->lastname;
553
    }
554
555
    /**
556
     * Add gamePlayerStatistic
557
     *
558
     * @param \Torakel\DatabaseBundle\Entity\GamePlayerStatistic $gamePlayerStatistic
559
     *
560
     * @return Player
561
     */
562
    public function addGamePlayerStatistic(\Torakel\DatabaseBundle\Entity\GamePlayerStatistic $gamePlayerStatistic)
563
    {
564
        $this->gamePlayerStatistics[] = $gamePlayerStatistic;
565
566
        return $this;
567
    }
568
569
    /**
570
     * Remove gamePlayerStatistic
571
     *
572
     * @param \Torakel\DatabaseBundle\Entity\GamePlayerStatistic $gamePlayerStatistic
573
     */
574
    public function removeGamePlayerStatistic(\Torakel\DatabaseBundle\Entity\GamePlayerStatistic $gamePlayerStatistic)
575
    {
576
        $this->gamePlayerStatistics->removeElement($gamePlayerStatistic);
577
    }
578
579
    /**
580
     * Get gamePlayerStatistics
581
     *
582
     * @return \Doctrine\Common\Collections\Collection
583
     */
584
    public function getGamePlayerStatistics()
585
    {
586
        return $this->gamePlayerStatistics;
587
    }
588
589
    /**
590
     * @return Country
591
     */
592
    public function getNationality()
593
    {
594
        return $this->nationality;
595
    }
596
597
    /**
598
     * @param Country $nationality
599
     */
600
    public function setNationality($nationality)
601
    {
602
        $this->nationality = $nationality;
603
    }
604
}
605