Completed
Push — master ( c087ad...47fff7 )
by Benedikt
02:33
created

RankingSystemListEntry   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 119
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 119
c 0
b 0
f 0
rs 10
wmc 10
lcom 2
cbo 4

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getNumberRankedEntities() 0 4 1
A getPlayer() 0 4 1
A getPoints() 0 4 1
A getRankingSystemList() 0 4 1
A setNumberRankedEntities() 0 4 1
A setPlayer() 0 4 1
A setPoints() 0 4 1
A setRankingSystemList() 0 8 2
A init() 0 5 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Created by PhpStorm.
5
 * User: benedikt
6
 * Date: 1/5/18
7
 * Time: 10:54 PM
8
 */
9
10
namespace Tfboe\FmLib\Entity\Traits;
11
12
13
use Doctrine\ORM\Mapping as ORM;
14
use Tfboe\FmLib\Entity\Helpers\SubClassData;
15
use Tfboe\FmLib\Entity\Helpers\UUIDEntity;
16
use Tfboe\FmLib\Entity\PlayerInterface;
17
use Tfboe\FmLib\Entity\RankingSystemListInterface;
18
19
/**
20
 * Trait RankingSystemListEntry
21
 * @package Tfboe\FmLib\Entity\Traits
22
 */
23
trait RankingSystemListEntry
24
{
25
  use UUIDEntity;
26
  use SubClassData;
27
28
//<editor-fold desc="Fields">
29
  /**
30
   * @ORM\ManyToOne(targetEntity="\Tfboe\FmLib\Entity\RankingSystemListInterface", inversedBy="entries")
31
   * @var RankingSystemListInterface
32
   */
33
  private $rankingSystemList;
34
35
  /**
36
   * @ORM\Column(type="float")
37
   * @var float
38
   */
39
  private $points;
40
41
  /**
42
   * @ORM\Column(type="integer")
43
   * @var int
44
   */
45
  private $numberRankedEntities;
46
47
  /**
48
   * @ORM\ManyToOne(targetEntity="\Tfboe\FmLib\Entity\PlayerInterface")
49
   * @ORM\JoinColumn(referencedColumnName="player_id")
50
   * @var PlayerInterface
51
   */
52
  private $player;
53
//</editor-fold desc="Fields">
54
55
//<editor-fold desc="Constructor">
56
//</editor-fold desc="Constructor">
57
58
//<editor-fold desc="Public Methods">
59
  /**
60
   * @return int
61
   */
62
  public function getNumberRankedEntities(): int
63
  {
64
    return $this->numberRankedEntities;
65
  }
66
67
  /**
68
   * @return PlayerInterface
69
   */
70
  public function getPlayer(): PlayerInterface
71
  {
72
    return $this->player;
73
  }
74
75
  /**
76
   * @return float
77
   */
78
  public function getPoints(): float
79
  {
80
    return $this->points;
81
  }
82
83
  /**
84
   * @return RankingSystemListInterface
85
   */
86
  public function getRankingSystemList(): RankingSystemListInterface
87
  {
88
    return $this->rankingSystemList;
89
  }
90
91
  /**
92
   * @param int $numberRankedEntities
93
   */
94
  public function setNumberRankedEntities(int $numberRankedEntities)
95
  {
96
    $this->numberRankedEntities = $numberRankedEntities;
97
  }
98
99
  /**
100
   * @param PlayerInterface $player
101
   */
102
  public function setPlayer(PlayerInterface $player)
103
  {
104
    $this->player = $player;
105
  }
106
107
  /**
108
   * @param float $points
109
   */
110
  public function setPoints(float $points)
111
  {
112
    $this->points = $points;
113
  }
114
115
  /**
116
   * @param RankingSystemListInterface $rankingSystemList
117
   */
118
  public function setRankingSystemList(RankingSystemListInterface $rankingSystemList)
119
  {
120
    if ($this->rankingSystemList !== null) {
121
      $this->rankingSystemList->getEntries()->remove($this->getPlayer()->getPlayerId());
122
    }
123
    $this->rankingSystemList = $rankingSystemList;
124
    $rankingSystemList->getEntries()->set($this->getPlayer()->getPlayerId(), $this);
125
  }
126
//</editor-fold desc="Public Methods">
127
128
//<editor-fold desc="Protected Final Methods">
129
  /**
130
   * RankingSystemListEntry init
131
   * @param string[] $keys list of additional fields
132
   */
133
  protected final function init(array $keys)
134
  {
135
    $this->numberRankedEntities = 0;
136
    $this->initSubClassData($keys);
137
  }
138
//</editor-fold desc="Protected Final Methods">
139
140
141
}