Passed
Push — develop ( 574080...0f5d99 )
by BENARD
04:30
created

Team::setPresentation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace VideoGamesRecords\CoreBundle\Entity;
4
5
use ApiPlatform\Core\Annotation\ApiFilter;
6
use ApiPlatform\Core\Annotation\ApiResource;
7
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
8
use ApiPlatform\Core\Serializer\Filter\GroupFilter;
9
use Doctrine\Common\Collections\ArrayCollection;
10
use Doctrine\Common\Collections\Collection;
11
use Doctrine\ORM\Mapping as ORM;
12
use Knp\DoctrineBehaviors\Contract\Entity\SluggableInterface;
13
use Knp\DoctrineBehaviors\Model\Sluggable\SluggableTrait;
14
use Gedmo\Timestampable\Traits\TimestampableEntity;
15
use Symfony\Component\Validator\Constraints as Assert;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Validator\Constraints 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...
16
use VideoGamesRecords\CoreBundle\Model\Entity\AverageChartRankTrait;
17
use VideoGamesRecords\CoreBundle\Model\Entity\AverageGameRankTrait;
18
use VideoGamesRecords\CoreBundle\Model\Entity\NbGameTrait;
19
use VideoGamesRecords\CoreBundle\Model\Entity\NbPlayerTrait;
20
use VideoGamesRecords\CoreBundle\Model\Entity\RankCupTrait;
21
use VideoGamesRecords\CoreBundle\Model\Entity\RankMedalTrait;
22
use VideoGamesRecords\CoreBundle\Model\Entity\RankPointBadgeTrait;
23
use VideoGamesRecords\CoreBundle\Model\Entity\RankPointGameTrait;
24
use VideoGamesRecords\CoreBundle\Model\Entity\RankPointChartTrait;
25
26
/**
27
 * @ORM\Table(name="vgr_team")
28
 * @ORM\Entity(repositoryClass="VideoGamesRecords\CoreBundle\Repository\TeamRepository")
29
 * @ORM\EntityListeners({"VideoGamesRecords\CoreBundle\EventListener\Entity\TeamListener"})
30
 * @ApiResource(attributes={"order"={"libTeam"}})
31
 * @ApiFilter(
32
 *     SearchFilter::class,
33
 *     properties={
34
 *          "libTeam": "partial"
35
 *      }
36
 * )
37
 * @ApiFilter(
38
 *     GroupFilter::class,
39
 *     arguments={
40
 *         "parameterName": "groups",
41
 *         "overrideDefaultGroups": false,
42
 *         "whitelist": {
43
 *             "team.rank.pointChart",
44
 *             "team.rank.pointGame",
45
 *             "team.rank.medal",
46
 *             "team.rank.cup",
47
 *             "team.rank.badge",
48
 *             "team.players"
49
 *         }
50
 *     }
51
 * )
52
 */
53
class Team implements SluggableInterface
54
{
55
    use TimestampableEntity;
56
    use SluggableTrait;
57
    use RankCupTrait;
58
    use RankMedalTrait;
59
    use RankPointBadgeTrait;
60
    use RankPointGameTrait;
61
    use RankPointChartTrait;
62
    use AverageChartRankTrait;
63
    use AverageGameRankTrait;
64
    use NbPlayerTrait;
65
    use NbGameTrait;
66
67
    const STATUS_OPENED = 'OPENED';
68
    const STATUS_CLOSED = 'CLOSED';
69
70
    const NUM_ITEMS = 20;
71
72
    /**
73
     * @ORM\Column(name="id", type="integer")
74
     * @ORM\Id
75
     * @ORM\GeneratedValue(strategy="IDENTITY")
76
     */
77
    private int $id;
78
79
    /**
80
     * @Assert\NotBlank()
81
     * @Assert\Length(min="5", max="50")
82
     * @ORM\Column(name="libTeam", type="string", length=50, nullable=false)
83
     */
84
    private string $libTeam;
85
86
    /**
87
     * @var string
88
     *
89
     * @Assert\NotBlank()
90
     * @Assert\Length(min="2", max="4")
91
     * @ORM\Column(name="tag", type="string", length=10, nullable=false)
92
     */
93
    private string $tag;
94
95
    /**
96
     * @Assert\Length(max="255")
97
     * @Assert\Url(
98
     *    protocols = {"http", "https"}
99
     * )
100
     * @ORM\Column(name="siteWeb", type="string", length=255, nullable=true)
101
     */
102
    private ?string $siteWeb;
103
104
    /**
105
     * @ORM\Column(name="logo", type="string", length=30, nullable=false)
106
     */
107
    private string $logo = 'default.png';
108
109
    /**
110
     * @ORM\Column(name="presentation", type="text", nullable=true)
111
     */
112
    private ?string $presentation;
113
114
    /**
115
     * @Assert\Choice({"CLOSED", "OPENED"})
116
     * @ORM\Column(name="status", type="string", length=30, nullable=false)
117
     */
118
    private string $status = self::STATUS_CLOSED;
119
120
    /**
121
     * @ORM\Column(name="nbMasterBadge", type="integer", nullable=false, options={"default" : 0})
122
     */
123
    private int $nbMasterBadge = 0;
124
125
    /**
126
     * @ORM\OneToMany(targetEntity="VideoGamesRecords\CoreBundle\Entity\Player", mappedBy="team")
127
     * @ORM\OrderBy({"pseudo" = "ASC"})
128
     */
129
    private Collection $players;
130
131
    /**
132
     * @ORM\OneToMany(targetEntity="VideoGamesRecords\CoreBundle\Entity\TeamGame", mappedBy="team")
133
     */
134
    private Collection $teamGame;
135
136
    /**
137
     * @ORM\OneToMany(targetEntity="VideoGamesRecords\CoreBundle\Entity\TeamBadge", mappedBy="team")
138
     */
139
    private Collection $teamBadge;
140
141
    /**
142
     * @var Player
143
     *
144
     * @Assert\NotNull
145
     * @ORM\ManyToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Player")
146
     * @ORM\JoinColumns({
147
     *   @ORM\JoinColumn(name="idLeader", referencedColumnName="id", nullable=false)
148
     * })
149
     */
150
    private Player $leader;
151
152
    /**
153
     * Constructor
154
     */
155
    public function __construct()
156
    {
157
        $this->players = new ArrayCollection();
158
        $this->teamGame = new ArrayCollection();
159
        $this->teamBadge = new ArrayCollection();
160
    }
161
162
    /**
163
     * @return string
164
     */
165
    public function __toString()
166
    {
167
        return sprintf('%s [%s]', $this->getLibTeam(), $this->id);
168
    }
169
170
171
    /**
172
     * Set id
173
     * @param integer $id
174
     * @return Team
175
     */
176
    public function setId(int $id): Team
177
    {
178
        $this->id = $id;
179
        return $this;
180
    }
181
182
    /**
183
     * Get id
184
     *
185
     * @return integer
186
     */
187
    public function getId(): int
188
    {
189
        return $this->id;
190
    }
191
192
    /**
193
     * Set libTeam
194
     * @param string $libTeam
195
     * @return Team
196
     */
197
    public function setLibTeam(string $libTeam): Team
198
    {
199
        $this->libTeam = $libTeam;
200
201
        return $this;
202
    }
203
204
    /**
205
     * Get libTeam
206
     *
207
     * @return string
208
     */
209
    public function getLibTeam(): string
210
    {
211
        return $this->libTeam;
212
    }
213
214
    /**
215
     * Set tag
216
     * @param string $tag
217
     * @return Team
218
     */
219
    public function setTag(string $tag): Team
220
    {
221
        $this->tag = $tag;
222
223
        return $this;
224
    }
225
226
    /**
227
     * Get tag
228
     *
229
     * @return string
230
     */
231
    public function getTag(): string
232
    {
233
        return $this->tag;
234
    }
235
236
    /**
237
     * Set leader
238
     * @param Player $leader
239
     * @return Team
240
     */
241
    public function setLeader(Player $leader): Team
242
    {
243
        $this->leader = $leader;
244
245
        return $this;
246
    }
247
248
    /**
249
     * Get leader
250
     * @return Player
251
     */
252
    public function getLeader(): Player
253
    {
254
        return $this->leader;
255
    }
256
257
    /**
258
     * Set siteWeb
259
     * @param string|null $siteWeb
260
     * @return Team
261
     */
262
    public function setSiteWeb(?string $siteWeb): Team
263
    {
264
        $this->siteWeb = $siteWeb;
265
266
        return $this;
267
    }
268
269
    /**
270
     * Get siteWeb
271
     *
272
     * @return string
273
     */
274
    public function getSiteWeb(): ?string
275
    {
276
        return $this->siteWeb;
277
    }
278
279
    /**
280
     * Set logo
281
     * @param string $logo
282
     * @return Team
283
     */
284
    public function setLogo(string $logo)
285
    {
286
        $this->logo = $logo;
287
288
        return $this;
289
    }
290
291
    /**
292
     * Get logo
293
     *
294
     * @return string
295
     */
296
    public function getLogo(): string
297
    {
298
        return $this->logo;
299
    }
300
301
    /**
302
     * Set presentation
303
     * @param string $presentation
304
     * @return Team
305
     */
306
    public function setPresentation(string $presentation): Team
307
    {
308
        $this->presentation = $presentation;
309
310
        return $this;
311
    }
312
313
    /**
314
     * Get presentation
315
     *
316
     * @return string
317
     */
318
    public function getPresentation(): ?string
319
    {
320
        return $this->presentation;
321
    }
322
323
    /**
324
     * Set status
325
     * @param string $status
326
     * @return Team
327
     */
328
    public function setStatus(string $status): Team
329
    {
330
        $this->status = $status;
331
332
        return $this;
333
    }
334
335
    /**
336
     * Get status
337
     *
338
     * @return string
339
     */
340
    public function getStatus(): string
341
    {
342
        return $this->status;
343
    }
344
345
    /**
346
     * Set nbMasterBadge
347
     * @param integer $nbMasterBadge
348
     * @return Team
349
     */
350
    public function setNbMasterBadge(int $nbMasterBadge): Team
351
    {
352
        $this->nbMasterBadge = $nbMasterBadge;
353
354
        return $this;
355
    }
356
357
    /**
358
     * Get nbMasterBadge
359
     *
360
     * @return integer
361
     */
362
    public function getNbMasterBadge(): int
363
    {
364
        return $this->nbMasterBadge;
365
    }
366
367
    /**
368
     * @return Collection
369
     */
370
    public function getPlayers(): Collection
371
    {
372
        return $this->players;
373
    }
374
375
    /**
376
     * @return Collection
377
     */
378
    public function getTeamGame(): Collection
379
    {
380
        return $this->teamGame;
381
    }
382
383
    /**
384
     * @return Collection
385
     */
386
    public function getTeamBadge(): Collection
387
    {
388
        return $this->teamBadge;
389
    }
390
391
    /**
392
     * @return bool
393
     */
394
    public function isOpened(): bool
395
    {
396
        return ($this->getStatus() == self::STATUS_OPENED);
397
    }
398
399
    /**
400
     * @return string[]
401
     */
402
    public function getSluggableFields(): array
403
    {
404
        return ['libTeam'];
405
    }
406
407
    /**
408
     * @return array
409
     */
410
    public static function getStatusChoices(): array
411
    {
412
        return [
413
            self::STATUS_CLOSED => self::STATUS_CLOSED,
414
            self::STATUS_OPENED => self::STATUS_OPENED,
415
        ];
416
    }
417
}
418