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

Team::removeGoal()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
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="team")
11
 */
12
class Team
13
{
14
15
    /**
16
     * @var integer
17
     * @ORM\Column(type="integer")
18
     * @ORM\Id
19
     * @ORM\GeneratedValue(strategy="AUTO")
20
     */
21
    private $id;
22
23
    /**
24
     * @var string
25
     * @ORM\Column(type="string")
26
     */
27
    protected $slug;
28
29
    /**
30
     * @var string
31
     * @ORM\Column(type="string")
32
     */
33
    protected $name;
34
35
    /**
36
     * @var string
37
     * @ORM\Column(type="text", nullable=true)
38
     */
39
    protected $altNames;
40
41
    /**
42
     * @var string
43
     * @ORM\Column(type="text")
44
     */
45
    protected $type;
46
47
    /**
48
     * @var \Torakel\DatabaseBundle\Entity\Club
49
     * @ORM\ManyToOne(targetEntity="\Torakel\DatabaseBundle\Entity\Club", inversedBy="teams")
50
     * @ORM\JoinColumn(name="club_id", referencedColumnName="id")
51
     */
52
    protected $club;
53
54
    /**
55
     * @var \Doctrine\Common\Collections\ArrayCollection;
56
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\Game", mappedBy="teamHome")
57
     */
58
    protected $homeGames;
59
60
    /**
61
     * @var \Doctrine\Common\Collections\ArrayCollection;
62
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\Game", mappedBy="teamAway")
63
     */
64
    protected $awayGames;
65
66
    /**
67
     * @var \Doctrine\Common\Collections\ArrayCollection;
68
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\Goal", mappedBy="team")
69
     */
70
    protected $goals;
71
72
    /**
73
     * @var \Doctrine\Common\Collections\ArrayCollection;
74
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\GamePlayer", mappedBy="team")
75
     */
76
    protected $gamePlayers;
77
78
    /**
79
     * @var \Doctrine\Common\Collections\ArrayCollection;
80
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\GamePlayerStatistic", mappedBy="team")
81
     */
82
    protected $gamePlayerStatistics;
83
84
    /**
85
     * @var \Doctrine\Common\Collections\ArrayCollection;
86
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\GameTeamStatistic", mappedBy="team")
87
     */
88
    protected $gameTeamStatistics;
89
90
    /**
91
     * @var \Doctrine\Common\Collections\ArrayCollection;
92
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\Substitution", mappedBy="team")
93
     */
94
    protected $substitutions;
95
96
    /**
97
     * @var \Doctrine\Common\Collections\ArrayCollection;
98
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\Card", mappedBy="team")
99
     */
100
    protected $cards;
101
102
    /**
103
     * @var \Doctrine\Common\Collections\ArrayCollection;
104
     * @ORM\OneToMany(targetEntity="\Torakel\DatabaseBundle\Entity\TablePosition", mappedBy="team")
105
     */
106
    protected $tablePositions;
107
108
    /**
109
     * @var integer
110
     * @ORM\Column(type="integer")
111
     */
112
    protected $position;
113
114
    /**
115
     * @var \DateTime
116
     * @ORM\Column(type="datetime", name="created_at")
117
     */
118
    protected $createdAt;
119
120
    /**
121
     * @var \DateTime
122
     * @ORM\Column(type="datetime", name="updated_at", nullable=true)
123
     */
124
    protected $updatedAt;
125
126
    /**
127
     * Constructor
128
     */
129 4
    public function __construct()
130
    {
131 4
        $this->homeGames = new \Doctrine\Common\Collections\ArrayCollection();
132 4
        $this->awayGames = new \Doctrine\Common\Collections\ArrayCollection();
133 4
        $this->goals = new \Doctrine\Common\Collections\ArrayCollection();
134 4
        $this->gamePlayers = new \Doctrine\Common\Collections\ArrayCollection();
135 4
        $this->gamePlayerStatistics = new \Doctrine\Common\Collections\ArrayCollection();
136 4
        $this->gameTeamStatistics = new \Doctrine\Common\Collections\ArrayCollection();
137 4
        $this->substitutions = new \Doctrine\Common\Collections\ArrayCollection();
138 4
        $this->cards = new \Doctrine\Common\Collections\ArrayCollection();
139
        $this->tablePositions = new \Doctrine\Common\Collections\ArrayCollection();
140
    }
141
142
    /**
143
     * Get id
144
     *
145
     * @return integer
146
     */
147
    public function getId()
148
    {
149
        return $this->id;
150
    }
151
152
    /**
153
     * Set slug
154
     *
155
     * @param string $slug
156
     *
157
     * @return Team
158
     */
159
    public function setSlug($slug)
160
    {
161
        $this->slug = $slug;
162
163
        return $this;
164
    }
165
166
    /**
167
     * Get slug
168
     *
169
     * @return string
170
     */
171
    public function getSlug()
172
    {
173
        return $this->slug;
174
    }
175
176
    /**
177
     * Set name
178
     *
179
     * @param string $name
180
     *
181
     * @return Team
182
     */
183
    public function setName($name)
184
    {
185
        $this->name = $name;
186
187
        return $this;
188
    }
189
190
    /**
191
     * Get name
192
     *
193
     * @return string
194
     */
195
    public function getName()
196
    {
197
        return $this->name;
198
    }
199
200
    /**
201
     * Add alt(ernative) name
202
     *
203
     * Adds an alternative name to the entity. For example external IDs.
204
     *
205
     * @param $name
206
     */
207
    public function addAltName($name)
208
    {
209
        $names = $this->getAltNames();
210
        if (in_array($name, $names) === false) {
211
            $names[] = $name;
212
            $this->setAltNames($names);
213
        }
214
    }
215
216
    /**
217
     * Set altNames
218
     *
219
     * @param array $altNames
220
     *
221
     * @return Player
222
     */
223
    public function setAltNames($altNames)
224
    {
225
        $this->altNames = implode('|', $altNames);
226
227
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type Torakel\DatabaseBundle\Entity\Team which is incompatible with the documented return type Torakel\DatabaseBundle\Entity\Player.
Loading history...
228
    }
229
230
    /**
231
     * Get altNames
232
     *
233
     * @return array
234
     */
235
    public function getAltNames()
236
    {
237
        return explode('|', $this->altNames);
238
    }
239
240
    /**
241
     * Set position
242
     *
243
     * @param integer $position
244
     *
245
     * @return Team
246
     */
247
    public function setPosition($position)
248
    {
249
        $this->position = $position;
250
251
        return $this;
252
    }
253
254
    /**
255
     * Get position
256
     *
257
     * @return integer
258
     */
259
    public function getPosition()
260
    {
261
        return $this->position;
262
    }
263
264
    /**
265
     * Set createdAt
266
     *
267
     * @param \DateTime $createdAt
268
     *
269
     * @return Team
270
     */
271
    public function setCreatedAt($createdAt)
272
    {
273
        $this->createdAt = $createdAt;
274
275
        return $this;
276
    }
277
278
    /**
279
     * Get createdAt
280
     *
281
     * @return \DateTime
282
     */
283
    public function getCreatedAt()
284
    {
285
        return $this->createdAt;
286
    }
287
288
    /**
289
     * Set updatedAt
290
     *
291
     * @param \DateTime $updatedAt
292
     *
293
     * @return Team
294
     */
295
    public function setUpdatedAt($updatedAt)
296
    {
297
        $this->updatedAt = $updatedAt;
298
299
        return $this;
300
    }
301
302
    /**
303
     * Get updatedAt
304
     *
305
     * @return \DateTime
306
     */
307
    public function getUpdatedAt()
308
    {
309
        return $this->updatedAt;
310
    }
311
312
    /**
313
     * Set club
314
     *
315
     * @param \Torakel\DatabaseBundle\Entity\Club $club
316
     *
317
     * @return Team
318
     */
319
    public function setClub(\Torakel\DatabaseBundle\Entity\Club $club = null)
320
    {
321
        $this->club = $club;
322
323
        return $this;
324
    }
325
326
    /**
327
     * Get club
328
     *
329
     * @return \Torakel\DatabaseBundle\Entity\Club
330
     */
331
    public function getClub()
332
    {
333
        return $this->club;
334
    }
335
336
    /**
337
     * Add homeGame
338
     *
339
     * @param \Torakel\DatabaseBundle\Entity\Game $homeGame
340
     *
341
     * @return Team
342
     */
343
    public function addHomeGame(\Torakel\DatabaseBundle\Entity\Game $homeGame)
344
    {
345
        $this->homeGames[] = $homeGame;
346
347
        return $this;
348
    }
349
350
    /**
351
     * Remove homeGame
352
     *
353
     * @param \Torakel\DatabaseBundle\Entity\Game $homeGame
354
     */
355
    public function removeHomeGame(\Torakel\DatabaseBundle\Entity\Game $homeGame)
356
    {
357
        $this->homeGames->removeElement($homeGame);
358
    }
359
360
    /**
361
     * Get homeGames
362
     *
363
     * @return \Doctrine\Common\Collections\Collection
364
     */
365
    public function getHomeGames()
366
    {
367
        return $this->homeGames;
368
    }
369
370
    /**
371
     * Add awayGame
372
     *
373
     * @param \Torakel\DatabaseBundle\Entity\Game $awayGame
374
     *
375
     * @return Team
376
     */
377
    public function addAwayGame(\Torakel\DatabaseBundle\Entity\Game $awayGame)
378
    {
379
        $this->awayGames[] = $awayGame;
380
381
        return $this;
382
    }
383
384
    /**
385
     * Remove awayGame
386
     *
387
     * @param \Torakel\DatabaseBundle\Entity\Game $awayGame
388
     */
389
    public function removeAwayGame(\Torakel\DatabaseBundle\Entity\Game $awayGame)
390
    {
391
        $this->awayGames->removeElement($awayGame);
392
    }
393
394
    /**
395
     * Get awayGames
396
     *
397
     * @return \Doctrine\Common\Collections\Collection
398
     */
399
    public function getAwayGames()
400
    {
401
        return $this->awayGames;
402
    }
403
404
    /**
405
     * Add goal
406
     *
407
     * @param \Torakel\DatabaseBundle\Entity\Goal $goal
408
     *
409
     * @return Team
410
     */
411
    public function addGoal(\Torakel\DatabaseBundle\Entity\Goal $goal)
412
    {
413
        $this->goals[] = $goal;
414
415
        return $this;
416
    }
417
418
    /**
419
     * Remove goal
420
     *
421
     * @param \Torakel\DatabaseBundle\Entity\Goal $goal
422
     */
423
    public function removeGoal(\Torakel\DatabaseBundle\Entity\Goal $goal)
424
    {
425
        $this->goals->removeElement($goal);
426
    }
427
428
    /**
429
     * Get goals
430
     *
431
     * @return \Doctrine\Common\Collections\Collection
432
     */
433
    public function getGoals()
434
    {
435
        return $this->goals;
436
    }
437
438
    /**
439
     * Add card
440
     *
441
     * @param \Torakel\DatabaseBundle\Entity\Card $card
442
     *
443
     * @return Team
444
     */
445
    public function addCard(\Torakel\DatabaseBundle\Entity\Card $card)
446
    {
447
        $this->cards[] = $card;
448
449
        return $this;
450
    }
451
452
    /**
453
     * Remove card
454
     *
455
     * @param \Torakel\DatabaseBundle\Entity\Card $card
456
     */
457
    public function removeCard(\Torakel\DatabaseBundle\Entity\Card $card)
458
    {
459
        $this->cards->removeElement($card);
460
    }
461
462
    /**
463
     * Get cards
464
     *
465
     * @return \Doctrine\Common\Collections\Collection
466
     */
467
    public function getCards()
468
    {
469
        return $this->cards;
470
    }
471
472
    /**
473
     * Add gamePlayer
474
     *
475
     * @param \Torakel\DatabaseBundle\Entity\GamePlayer $gamePlayer
476
     *
477
     * @return Team
478
     */
479
    public function addGamePlayer(\Torakel\DatabaseBundle\Entity\GamePlayer $gamePlayer)
480
    {
481
        $this->gamePlayers[] = $gamePlayer;
482
483
        return $this;
484
    }
485
486
    /**
487
     * Remove gamePlayer
488
     *
489
     * @param \Torakel\DatabaseBundle\Entity\GamePlayer $gamePlayer
490
     */
491
    public function removeGamePlayer(\Torakel\DatabaseBundle\Entity\GamePlayer $gamePlayer)
492
    {
493
        $this->gamePlayers->removeElement($gamePlayer);
494
    }
495
496
    /**
497
     * Get gamePlayers
498
     *
499
     * @return \Doctrine\Common\Collections\Collection
500
     */
501
    public function getGamePlayers()
502
    {
503
        return $this->gamePlayers;
504
    }
505
506
    /**
507
     * Add substitution
508
     *
509
     * @param \Torakel\DatabaseBundle\Entity\Substitution $substitution
510
     *
511
     * @return Team
512
     */
513
    public function addSubstitution(\Torakel\DatabaseBundle\Entity\Substitution $substitution)
514
    {
515
        $this->substitutions[] = $substitution;
516
517
        return $this;
518
    }
519
520
    /**
521
     * Remove substitution
522
     *
523
     * @param \Torakel\DatabaseBundle\Entity\Substitution $substitution
524
     */
525
    public function removeSubstitution(\Torakel\DatabaseBundle\Entity\Substitution $substitution)
526
    {
527
        $this->substitutions->removeElement($substitution);
528
    }
529
530
    /**
531
     * Get substitutions
532
     *
533
     * @return \Doctrine\Common\Collections\Collection
534
     */
535
    public function getSubstitutions()
536
    {
537
        return $this->substitutions;
538
    }
539
540
541
    /**
542
     * @ORM\PrePersist
543
     */
544
    public function prePersist()
545
    {
546
        $this->createdAt = new \DateTime();
547
        $altNames = $this->getAltNames();
548
        $altNames[999999] = '';
549
        $this->setAltNames($altNames);
550
    }
551
552
    /**
553
     * @ORM\PreUpdate
554
     */
555
    public function preUpdate()
556
    {
557
        $this->updatedAt = new \DateTime();
558
    }
559
560
    /**
561
     * Set type
562
     *
563
     * @param string $type
564
     *
565
     * @return Team
566
     */
567
    public function setType($type)
568
    {
569
        $this->type = $type;
570
571
        return $this;
572
    }
573
574
    /**
575
     * Get type
576
     *
577
     * @return string
578
     */
579
    public function getType()
580
    {
581
        return $this->type;
582
    }
583
584
    /**
585
     * Add tablePosition
586
     *
587
     * @param \Torakel\DatabaseBundle\Entity\TablePosition $tablePosition
588
     *
589
     * @return Team
590
     */
591
    public function addTablePosition(\Torakel\DatabaseBundle\Entity\TablePosition $tablePosition)
592
    {
593
        $this->tablePositions[] = $tablePosition;
594
595
        return $this;
596
    }
597
598
    /**
599
     * Remove tablePosition
600
     *
601
     * @param \Torakel\DatabaseBundle\Entity\TablePosition $tablePosition
602
     */
603
    public function removeTablePosition(\Torakel\DatabaseBundle\Entity\TablePosition $tablePosition)
604
    {
605
        $this->tablePositions->removeElement($tablePosition);
606
    }
607
608
    /**
609
     * Get tablePositions
610
     *
611
     * @return \Doctrine\Common\Collections\Collection
612
     */
613
    public function getTablePositions()
614
    {
615
        return $this->tablePositions;
616
    }
617
618
    /**
619
     * Add gamePlayerStatistic
620
     *
621
     * @param \Torakel\DatabaseBundle\Entity\GamePlayerStatistic $gamePlayerStatistic
622
     *
623
     * @return Team
624
     */
625
    public function addGamePlayerStatistic(\Torakel\DatabaseBundle\Entity\GamePlayerStatistic $gamePlayerStatistic)
626
    {
627
        $this->gamePlayerStatistics[] = $gamePlayerStatistic;
628
629
        return $this;
630
    }
631
632
    /**
633
     * Remove gamePlayerStatistic
634
     *
635
     * @param \Torakel\DatabaseBundle\Entity\GamePlayerStatistic $gamePlayerStatistic
636
     */
637
    public function removeGamePlayerStatistic(\Torakel\DatabaseBundle\Entity\GamePlayerStatistic $gamePlayerStatistic)
638
    {
639
        $this->gamePlayerStatistics->removeElement($gamePlayerStatistic);
640
    }
641
642
    /**
643
     * Get gamePlayerStatistics
644
     *
645
     * @return \Doctrine\Common\Collections\Collection
646
     */
647
    public function getGamePlayerStatistics()
648
    {
649
        return $this->gamePlayerStatistics;
650
    }
651
652
    /**
653
     * Add gameTeamStatistic
654
     *
655
     * @param \Torakel\DatabaseBundle\Entity\GameTeamStatistic $gameTeamStatistic
656
     *
657
     * @return Team
658
     */
659
    public function addGameTeamStatistic(\Torakel\DatabaseBundle\Entity\GameTeamStatistic $gameTeamStatistic)
660
    {
661
        $this->gameTeamStatistics[] = $gameTeamStatistic;
662
663
        return $this;
664
    }
665
666
    /**
667
     * Remove gameTeamStatistic
668
     *
669
     * @param \Torakel\DatabaseBundle\Entity\GameTeamStatistic $gameTeamStatistic
670
     */
671
    public function removeGameTeamStatistic(\Torakel\DatabaseBundle\Entity\GameTeamStatistic $gameTeamStatistic)
672
    {
673
        $this->gameTeamStatistics->removeElement($gameTeamStatistic);
674
    }
675
676
    /**
677
     * Get gameTeamStatistics
678
     *
679
     * @return \Doctrine\Common\Collections\Collection
680
     */
681
    public function getGameTeamStatistics()
682
    {
683
        return $this->gameTeamStatistics;
684
    }
685
}
686