| Total Complexity | 47 | 
| Total Lines | 594 | 
| Duplicated Lines | 0 % | 
| Changes | 6 | ||
| Bugs | 0 | Features | 1 | 
Complex classes like Player often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Player, and based on these observations, apply Extract Interface, too.
| 1 | <?php | ||
| 76 | #[ORM\Table(name:'vgr_player')] | ||
| 77 | #[ORM\Entity(repositoryClass: PlayerRepository::class)] | ||
| 78 | #[ORM\EntityListeners(["VideoGamesRecords\CoreBundle\EventListener\Entity\PlayerListener"])] | ||
| 79 | #[ORM\Index(name: "idx_point_game", columns: ["point_game"])] | ||
| 80 | #[ORM\Index(name: "idx_chart_rank", columns: ["chart_rank0", "chart_rank1", "chart_rank2", "chart_rank3"])] | ||
| 81 | #[ORM\Index(name: "idx_game_rank", columns: ["game_rank0", "game_rank1", "game_rank2", "game_rank3"])] | ||
| 82 | #[ApiResource( | ||
| 83 | operations: [ | ||
| 84 | new GetCollection(), | ||
| 85 | new GetCollection( | ||
| 86 | uriTemplate: '/players/autocomplete', | ||
| 87 | controller: Autocomplete::class, | ||
| 88 | normalizationContext: ['groups' => [ | ||
| 89 | 'player:read:minimal'] | ||
| 90 | ], | ||
| 91 | openapi: new Model\Operation( | ||
| 92 | summary: 'Retrieves players by autocompletion', | ||
| 93 | description: 'Retrieves players by autocompletion' | ||
| 94 | ), | ||
| 95 | /*openapiContext: [ | ||
| 96 | 'parameters' => [ | ||
| 97 | [ | ||
| 98 | 'name' => 'query', | ||
| 99 | 'in' => 'query', | ||
| 100 | 'type' => 'string', | ||
| 101 | 'required' => true | ||
| 102 | ] | ||
| 103 | ] | ||
| 104 | ]*/ | ||
| 105 | ), | ||
| 106 | new GetCollection( | ||
| 107 | uriTemplate: '/players/ranking-point-chart', | ||
| 108 | controller: GetRankingPointChart::class, | ||
| 109 | ), | ||
| 110 | new GetCollection( | ||
| 111 | uriTemplate: '/players/ranking-point-game', | ||
| 112 | controller: GetRankingPointGame::class, | ||
| 113 | ), | ||
| 114 | new GetCollection( | ||
| 115 | uriTemplate: '/players/ranking-medal', | ||
| 116 | controller: GetRankingMedals::class, | ||
| 117 | ), | ||
| 118 | new GetCollection( | ||
| 119 | uriTemplate: '/players/ranking-cup', | ||
| 120 | controller: GetRankingCup::class, | ||
| 121 | ), | ||
| 122 | new GetCollection( | ||
| 123 | uriTemplate: '/players/ranking-badge', | ||
| 124 | controller: GetRankingBadge::class, | ||
| 125 | ), | ||
| 126 | new GetCollection( | ||
| 127 | uriTemplate: '/players/ranking-proof', | ||
| 128 | controller: GetRankingProof::class, | ||
| 129 | ), | ||
| 130 | new Get(), | ||
| 131 | new Get( | ||
| 132 |             uriTemplate: '/players/{id}/get-nb-lost-position', | ||
| 133 | controller: GetNbLostPosition::class, | ||
| 134 | ), | ||
| 135 | new Get( | ||
| 136 |             uriTemplate: '/players/{id}/get-nb-new-lost-position', | ||
| 137 | controller: GetNbNewLostPosition::class, | ||
| 138 | ), | ||
| 139 | new Get( | ||
| 140 |             uriTemplate: '/players/{id}/can-ask-proof', | ||
| 141 | controller: CanAskProof::class, | ||
| 142 | ), | ||
| 143 | new Get( | ||
| 144 |             uriTemplate: '/players/{id}/player-chart-stats', | ||
| 145 | controller: PlayerChartGetStats::class, | ||
| 146 | normalizationContext: ['groups' => [ | ||
| 147 | 'player-chart-status:read'] | ||
| 148 | ], | ||
| 149 | ), | ||
| 150 | new Get( | ||
| 151 |             uriTemplate: '/players/{id}/game-stats', | ||
| 152 | controller: GameGetStats::class, | ||
| 153 | normalizationContext: ['groups' => [ | ||
| 154 | 'player-game:read', 'player-game:game', 'game:read', | ||
| 155 | 'game:platforms', 'platform:read', | ||
| 156 | 'player-game.statuses', 'player-chart-status:read'] | ||
| 157 | ], | ||
| 158 | ), | ||
| 159 | new Get( | ||
| 160 |             uriTemplate: '/players/{id}/games-from-lost-positions', | ||
| 161 | controller: GetGamesFromLostPositions::class, | ||
| 162 | normalizationContext: ['groups' => [ | ||
| 163 | 'game:read:minimal'] | ||
| 164 | ], | ||
| 165 | ), | ||
| 166 | new GetCollection( | ||
| 167 |             uriTemplate: '/players/{id}/badges', | ||
| 168 | controller: GetBadges::class, | ||
| 169 | normalizationContext: ['groups' => [ | ||
| 170 | 'player-badge:read', 'player-badge:badge', 'badge:read', | ||
| 171 | 'badge:serie', 'serie:read', | ||
| 172 | 'badge:game', 'game:read', | ||
| 173 | 'badge:platform', 'platform:read', | ||
| 174 | ] | ||
| 175 | ] | ||
| 176 | ), | ||
| 177 | new GetCollection( | ||
| 178 |             uriTemplate: '/players/{id}/friends', | ||
| 179 | controller: GetFriends::class, | ||
| 180 | normalizationContext: ['groups' => ['player:read:minimal']] | ||
| 181 | ), | ||
| 182 | new Post( | ||
| 183 | uriTemplate: '/players/add-friend', | ||
| 184 | status: 200, | ||
| 185 | controller: AddFriend::class, | ||
| 186 | /*openapi: new Model\Operation( | ||
| 187 | responses: [ | ||
| 188 | '200' => [ | ||
| 189 | 'description' => 'Friend added successfully', | ||
| 190 | 'content' => [ | ||
| 191 | 'application/json' => [ | ||
| 192 | 'schema' => [ | ||
| 193 | 'type' => 'object', | ||
| 194 | 'properties' => [ | ||
| 195 | 'success' => [ | ||
| 196 | 'type' => 'boolean', | ||
| 197 | 'example' => true | ||
| 198 | ] | ||
| 199 | ] | ||
| 200 | ] | ||
| 201 | ] | ||
| 202 | ] | ||
| 203 | ], | ||
| 204 | '400' => [ | ||
| 205 | 'description' => 'Bad request - friend_id is required' | ||
| 206 | ], | ||
| 207 | '404' => [ | ||
| 208 | 'description' => 'Friend not found' | ||
| 209 | ] | ||
| 210 | ], | ||
| 211 | summary: 'Add a friend to the current player', | ||
| 212 | description: 'Add a friend to the current player by providing friend_id in request body', | ||
| 213 | requestBody: new Model\RequestBody( | ||
| 214 | content: new \ArrayObject([ | ||
| 215 | 'application/json' => [ | ||
| 216 | 'schema' => [ | ||
| 217 | 'type' => 'object', | ||
| 218 | 'properties' => [ | ||
| 219 | 'friend_id' => [ | ||
| 220 | 'type' => 'integer', | ||
| 221 | 'example' => 0 | ||
| 222 | ] | ||
| 223 | ], | ||
| 224 | 'required' => ['friend_id'] | ||
| 225 | ] | ||
| 226 | ] | ||
| 227 | ]) | ||
| 228 | ) | ||
| 229 | ),*/ | ||
| 230 |             security: 'is_granted("ROLE_USER")', | ||
| 231 | validate: false | ||
| 232 | ), | ||
| 233 | new Post( | ||
| 234 |             uriTemplate: '/players/{id}/order-master-badges', | ||
| 235 | controller: OrderMasterBadges::class, | ||
| 236 | security: 'object.getUserId() == user.getId()', | ||
| 237 | openapi: new Model\Operation( | ||
| 238 | summary: 'Order master badges for a player', | ||
| 239 | requestBody: new Model\RequestBody( | ||
| 240 | content: new \ArrayObject([ | ||
| 241 | 'application/json' => [ | ||
| 242 | 'schema' => [ | ||
| 243 | 'type' => 'array', | ||
| 244 | 'items' => [ | ||
| 245 | 'type' => 'object', | ||
| 246 | 'properties' => [ | ||
| 247 | 'id' => ['type' => 'integer'], | ||
| 248 | 'mbOrder' => ['type' => 'integer'] | ||
| 249 | ], | ||
| 250 | 'required' => ['id', 'mbOrder'] | ||
| 251 | ] | ||
| 252 | ] | ||
| 253 | ] | ||
| 254 | ]) | ||
| 255 | ) | ||
| 256 | ) | ||
| 257 | ), | ||
| 258 | new Put( | ||
| 259 | denormalizationContext: ['groups' => ['player:update']], | ||
| 260 |             security: 'is_granted("ROLE_PLAYER") and object.getUserId() == user.getId()' | ||
| 261 | ), | ||
| 262 | ], | ||
| 263 | normalizationContext: ['groups' => [ | ||
| 264 | 'player:read', | ||
| 265 | 'player:team', 'team:read:minimal', | ||
| 266 | 'player:country', 'country:read', | ||
| 267 | 'player:status', 'player-status:read'] | ||
| 268 | ], | ||
| 269 | order: ['pseudo' => 'ASC'], | ||
| 270 | )] | ||
| 271 | #[ApiResource( | ||
| 272 |     uriTemplate: '/teams/{id}/players', | ||
| 273 | uriVariables: [ | ||
| 274 | 'id' => new Link(fromClass: Team::class, toProperty: 'team'), | ||
| 275 | ], | ||
| 276 | operations: [ new GetCollection() ], | ||
| 277 | normalizationContext: ['groups' => ['player:read:minimal']], | ||
| 278 | )] | ||
| 279 | #[ApiFilter( | ||
| 280 | SearchFilter::class, | ||
| 281 | properties: [ | ||
| 282 | 'pseudo' => 'partial', | ||
| 283 | 'user.enabled' => 'exact', | ||
| 284 | ] | ||
| 285 | )] | ||
| 286 | #[ApiFilter( | ||
| 287 | OrderFilter::class, | ||
| 288 | properties: [ | ||
| 289 | 'id' => 'ASC', | ||
| 290 | 'pseudo' => 'ASC', | ||
| 291 | 'createdAt' => 'ASC', | ||
| 292 | 'nbConnexion' => 'DESC', | ||
| 293 | 'lastLogin' => 'DESC', | ||
| 294 | 'nbForumMessage' => 'DESC', | ||
| 295 | 'nbChart' => 'DESC', | ||
| 296 | 'nbVideo' => 'DESC', | ||
| 297 | 'nbGame' => 'DESC', | ||
| 298 | 'pointGame' => 'DESC', | ||
| 299 | ] | ||
| 300 | )] | ||
| 301 | #[ApiFilter(DateFilter::class, properties: ['lastLogin' => DateFilterInterface::EXCLUDE_NULL])] | ||
| 302 | #[ApiFilter(RangeFilter::class, properties: ['nbVideo'])] | ||
| 303 | #[ApiFilter(BooleanFilter::class, properties: ['hasDonate'])] | ||
| 304 | #[ApiFilter(PlayerSearchFilter::class)] | ||
| 305 | class Player | ||
| 306 | { | ||
| 307 | use TimestampableEntity; | ||
| 308 | use RankCupTrait; | ||
| 309 | use GameRank0Trait; | ||
| 310 | use GameRank1Trait; | ||
| 311 | use GameRank2Trait; | ||
| 312 | use GameRank3Trait; | ||
| 313 | use RankMedalTrait; | ||
| 314 | use ChartRank0Trait; | ||
| 315 | use ChartRank1Trait; | ||
| 316 | use ChartRank2Trait; | ||
| 317 | use ChartRank3Trait; | ||
| 318 | use ChartRank4Trait; | ||
| 319 | use ChartRank5Trait; | ||
| 320 | use RankPointBadgeTrait; | ||
| 321 | use PointBadgeTrait; | ||
| 322 | use RankPointChartTrait; | ||
| 323 | use PointChartTrait; | ||
| 324 | use RankPointGameTrait; | ||
| 325 | use PointGameTrait; | ||
| 326 | use AverageChartRankTrait; | ||
| 327 | use AverageGameRankTrait; | ||
| 328 | use PlayerCommunicationDataTrait; | ||
| 329 | use PlayerPersonalDataTrait; | ||
| 330 | use NbChartTrait; | ||
| 331 | use NbChartProvenTrait; | ||
| 332 | use NbGameTrait; | ||
| 333 | use NbVideoTrait; | ||
| 334 | use NbMasterBadgeTrait; | ||
| 335 | |||
| 336 | #[ORM\Column(nullable: false)] | ||
| 337 | private int $user_id; | ||
| 338 | |||
| 339 | #[ApiProperty(identifier: true)] | ||
| 340 | #[ORM\Id, ORM\Column, ORM\GeneratedValue] | ||
| 341 | private ?int $id = null; | ||
| 342 | |||
| 343 | #[Assert\Length(min: 3, max: 50)] | ||
| 344 | #[ORM\Column(length: 50, nullable: false, unique: true)] | ||
| 345 | private string $pseudo; | ||
| 346 | |||
| 347 | #[Assert\Length(max: 100)] | ||
| 348 | #[ORM\Column(length: 100, nullable: false, options: ['default' => "default.jpg"])] | ||
| 349 | private string $avatar = 'default.jpg'; | ||
| 350 | |||
| 351 | #[Assert\Length(max: 50)] | ||
| 352 | #[ORM\Column(length: 50, nullable: true)] | ||
| 353 | private ?string $gamerCard = null; | ||
| 354 | |||
| 355 | #[ORM\Column(nullable: false, options: ['default' => 0])] | ||
| 356 | private int $rankProof = 0; | ||
| 357 | |||
| 358 | #[ORM\Column(nullable: false, options: ['default' => 0])] | ||
| 359 | private int $rankCountry = 0; | ||
| 360 | |||
| 361 | #[ORM\Column(nullable: false, options: ['default' => 0])] | ||
| 362 | private int $nbChartMax = 0; | ||
| 363 | |||
| 364 | #[ORM\Column(nullable: false, options: ['default' => 0])] | ||
| 365 | private int $nbChartWithPlatform = 0; | ||
| 366 | |||
| 367 | #[ORM\Column(nullable: false, options: ['default' => 0])] | ||
| 368 | private int $nbChartDisabled = 0; | ||
| 369 | |||
| 370 | #[ORM\Column(nullable: true)] | ||
| 371 | protected ?DateTime $lastLogin = null; | ||
| 372 | |||
| 373 | #[ORM\Column(nullable: false, options: ['default' => 0])] | ||
| 374 | protected int $nbConnexion = 0; | ||
| 375 | |||
| 376 | #[ORM\Column(nullable: false, options: ['default' => false])] | ||
| 377 | private bool $boolMaj = false; | ||
| 378 | |||
| 379 | #[ORM\Column(nullable: false, options: ['default' => false])] | ||
| 380 | private bool $hasDonate = false; | ||
| 381 | |||
| 382 | #[ORM\ManyToOne(targetEntity: Team::class, inversedBy: 'players')] | ||
| 383 | #[ORM\JoinColumn(name:'team_id', referencedColumnName:'id', nullable:true, onDelete: 'SET NULL')] | ||
| 384 | private ?Team $team; | ||
| 385 | |||
| 386 | #[ORM\Column(nullable: true)] | ||
| 387 | protected ?DateTime $lastDisplayLostPosition; | ||
| 388 | |||
| 389 | #[ORM\ManyToOne(targetEntity: PlayerStatus::class)] | ||
| 390 | #[ORM\JoinColumn(name:'status_id', referencedColumnName:'id', nullable:false)] | ||
| 391 | private PlayerStatus $status; | ||
| 392 | |||
| 393 | #[ORM\Column(length: 128)] | ||
| 394 | #[Gedmo\Slug(fields: ['pseudo'])] | ||
| 395 | protected string $slug; | ||
| 396 | |||
| 397 | |||
| 398 | /** | ||
| 399 | * @var Collection<int, Proof> | ||
| 400 | */ | ||
| 401 | #[ORM\OneToMany(targetEntity: Proof::class, mappedBy: 'playerResponding')] | ||
| 402 | private Collection $proofRespondings; | ||
|  | |||
| 403 | |||
| 404 | /** | ||
| 405 | * @var Collection<int, PlayerGame> | ||
| 406 | */ | ||
| 407 | #[ORM\OneToMany(targetEntity: PlayerGame::class, mappedBy: 'player')] | ||
| 408 | private Collection $playerGame; | ||
| 409 | |||
| 410 | /** | ||
| 411 | * @var Collection<int, PlayerChart> | ||
| 412 | */ | ||
| 413 | #[ORM\OneToMany(targetEntity: PlayerChart::class, mappedBy: 'player')] | ||
| 414 | private Collection $playerCharts; | ||
| 415 | |||
| 416 | /** | ||
| 417 | * @var Collection<int, Player> | ||
| 418 | */ | ||
| 419 | #[ORM\ManyToMany(targetEntity: Player::class)] | ||
| 420 | #[ORM\JoinTable(name: 'vgr_friend')] | ||
| 421 | #[ORM\JoinColumn(name: 'player_id', referencedColumnName: 'id')] | ||
| 422 | #[ORM\InverseJoinColumn(name: 'friend_id', referencedColumnName: 'id')] | ||
| 423 | private Collection $friends; | ||
| 424 | |||
| 425 | public function __construct() | ||
| 426 |     { | ||
| 427 | $this->playerGame = new ArrayCollection(); | ||
| 428 | $this->playerCharts = new ArrayCollection(); | ||
| 429 | $this->friends = new ArrayCollection(); | ||
| 430 | } | ||
| 431 | |||
| 432 | public function __toString() | ||
| 433 |     { | ||
| 434 |         return sprintf('%s (%d)', $this->getPseudo(), $this->getId()); | ||
| 435 | } | ||
| 436 | |||
| 437 | public function setId(int $id): void | ||
| 438 |     { | ||
| 439 | $this->id = $id; | ||
| 440 | } | ||
| 441 | |||
| 442 | public function getId(): ?int | ||
| 443 |     { | ||
| 444 | return $this->id; | ||
| 445 | } | ||
| 446 | |||
| 447 | public function setPseudo(string $pseudo): void | ||
| 448 |     { | ||
| 449 | $this->pseudo = $pseudo; | ||
| 450 | } | ||
| 451 | |||
| 452 | public function getPseudo(): string | ||
| 453 |     { | ||
| 454 | return $this->pseudo; | ||
| 455 | } | ||
| 456 | |||
| 457 | public function setAvatar(string $avatar): void | ||
| 458 |     { | ||
| 459 | $this->avatar = $avatar; | ||
| 460 | } | ||
| 461 | |||
| 462 | public function getAvatar(): string | ||
| 463 |     { | ||
| 464 | return $this->avatar; | ||
| 465 | } | ||
| 466 | |||
| 467 | public function setGamerCard(string $gamerCard): void | ||
| 468 |     { | ||
| 469 | $this->gamerCard = $gamerCard; | ||
| 470 | } | ||
| 471 | |||
| 472 | public function getGamerCard(): ?string | ||
| 473 |     { | ||
| 474 | return $this->gamerCard; | ||
| 475 | } | ||
| 476 | |||
| 477 | |||
| 478 | public function setRankProof(int $rankProof): void | ||
| 479 |     { | ||
| 480 | $this->rankProof = $rankProof; | ||
| 481 | } | ||
| 482 | |||
| 483 | public function getRankProof(): ?int | ||
| 484 |     { | ||
| 485 | return $this->rankProof; | ||
| 486 | } | ||
| 487 | |||
| 488 | public function setRankCountry(int $rankCountry): void | ||
| 489 |     { | ||
| 490 | $this->rankCountry = $rankCountry; | ||
| 491 | } | ||
| 492 | |||
| 493 | public function getRankCountry(): ?int | ||
| 494 |     { | ||
| 495 | return $this->rankCountry; | ||
| 496 | } | ||
| 497 | |||
| 498 | public function setNbChartMax(int $nbChartMax): void | ||
| 499 |     { | ||
| 500 | $this->nbChartMax = $nbChartMax; | ||
| 501 | } | ||
| 502 | |||
| 503 | public function getNbChartMax(): int | ||
| 504 |     { | ||
| 505 | return $this->nbChartMax; | ||
| 506 | } | ||
| 507 | |||
| 508 | public function setNbChartWithPlatform(int $nbChartWithPlatform): void | ||
| 509 |     { | ||
| 510 | $this->nbChartWithPlatform = $nbChartWithPlatform; | ||
| 511 | } | ||
| 512 | |||
| 513 | public function getNbChartWithPlatform(): int | ||
| 514 |     { | ||
| 515 | return $this->nbChartWithPlatform; | ||
| 516 | } | ||
| 517 | |||
| 518 | public function setNbChartDisabled(int $nbChartDisabled): void | ||
| 519 |     { | ||
| 520 | $this->nbChartDisabled = $nbChartDisabled; | ||
| 521 | } | ||
| 522 | |||
| 523 | public function getNbChartDisabled(): int | ||
| 524 |     { | ||
| 525 | return $this->nbChartDisabled; | ||
| 526 | } | ||
| 527 | |||
| 528 | public function getLastLogin(): ?DateTime | ||
| 529 |     { | ||
| 530 | return $this->lastLogin; | ||
| 531 | } | ||
| 532 | |||
| 533 | public function setLastLogin(?DateTime $time = null): void | ||
| 534 |     { | ||
| 535 | $this->lastLogin = $time; | ||
| 536 | } | ||
| 537 | |||
| 538 | /** | ||
| 539 | * @return int | ||
| 540 | */ | ||
| 541 | public function getUserId(): int | ||
| 542 |     { | ||
| 543 | return $this->user_id; | ||
| 544 | } | ||
| 545 | |||
| 546 | public function setUserId($userId): Player | ||
| 547 |     { | ||
| 548 | $this->user_id = $userId; | ||
| 549 | return $this; | ||
| 550 | } | ||
| 551 | |||
| 552 | public function setTeam(?Team $team = null): void | ||
| 553 |     { | ||
| 554 | $this->team = $team; | ||
| 555 | } | ||
| 556 | |||
| 557 | public function getTeam(): ?Team | ||
| 558 |     { | ||
| 559 | return $this->team; | ||
| 560 | } | ||
| 561 | |||
| 562 | public function getLastDisplayLostPosition(): ?DateTime | ||
| 563 |     { | ||
| 564 | return $this->lastDisplayLostPosition; | ||
| 565 | } | ||
| 566 | |||
| 567 | |||
| 568 | public function setLastDisplayLostPosition(?DateTime $lastDisplayLostPosition = null): void | ||
| 569 |     { | ||
| 570 | $this->lastDisplayLostPosition = $lastDisplayLostPosition; | ||
| 571 | } | ||
| 572 | |||
| 573 | public function setBoolMaj(bool $boolMaj): void | ||
| 574 |     { | ||
| 575 | $this->boolMaj = $boolMaj; | ||
| 576 | } | ||
| 577 | |||
| 578 | public function getBoolMaj(): bool | ||
| 579 |     { | ||
| 580 | return $this->boolMaj; | ||
| 581 | } | ||
| 582 | |||
| 583 | public function getHasDonate(): bool | ||
| 584 |     { | ||
| 585 | return $this->hasDonate; | ||
| 586 | } | ||
| 587 | |||
| 588 | public function setHasDonate(bool $hasDonate): void | ||
| 589 |     { | ||
| 590 | $this->hasDonate = $hasDonate; | ||
| 591 | } | ||
| 592 | |||
| 593 | public function setStatus(PlayerStatus $status): void | ||
| 594 |     { | ||
| 595 | $this->status = $status; | ||
| 596 | } | ||
| 597 | |||
| 598 | public function getStatus(): PlayerStatus | ||
| 599 |     { | ||
| 600 | return $this->status; | ||
| 601 | } | ||
| 602 | |||
| 603 | public function getSlug(): string | ||
| 604 |     { | ||
| 605 | return $this->slug; | ||
| 606 | } | ||
| 607 | |||
| 608 | /** | ||
| 609 | * @return int | ||
| 610 | */ | ||
| 611 | public function getNbConnexion(): int | ||
| 612 |     { | ||
| 613 | return $this->nbConnexion; | ||
| 614 | } | ||
| 615 | |||
| 616 | public function setNbConnexion(int $nbConnexion): void | ||
| 619 | } | ||
| 620 | |||
| 621 | |||
| 622 | public function getSluggableFields(): array | ||
| 623 |     { | ||
| 624 | return ['pseudo']; | ||
| 625 | } | ||
| 626 | |||
| 627 | public function getInitial(): string | ||
| 628 |     { | ||
| 629 | return substr($this->pseudo, 0, 1); | ||
| 630 | } | ||
| 631 | |||
| 632 | |||
| 633 | public function isLeader(): bool | ||
| 634 |     { | ||
| 635 | return ($this->getTeam() !== null) && ($this->getTeam()->getLeader()->getId() === $this->getId()); | ||
| 636 | } | ||
| 637 | |||
| 638 | public function getPlayerCharts(): Collection | ||
| 641 | } | ||
| 642 | |||
| 643 | public function getFriends(): Collection | ||
| 644 |     { | ||
| 645 | return $this->friends; | ||
| 646 | } | ||
| 647 | |||
| 648 | public function addFriend(Player $friend): self | ||
| 649 |     { | ||
| 650 |         if (!$this->friends->contains($friend)) { | ||
| 651 | $this->friends->add($friend); | ||
| 652 | } | ||
| 653 | |||
| 654 | return $this; | ||
| 655 | } | ||
| 656 | |||
| 657 | public function removeFriend(Player $friend): self | ||
| 658 |     { | ||
| 659 | $this->friends->removeElement($friend); | ||
| 660 | |||
| 661 | return $this; | ||
| 662 | } | ||
| 663 | |||
| 664 | public function getUrl(): string | ||
| 670 | ); | ||
| 671 | } | ||
| 672 | } | ||
| 673 |