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

RankingSystemList   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 106
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 106
c 0
b 0
f 0
rs 10
wmc 9
lcom 2
cbo 3

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getEntries() 0 4 1
A getLastEntryTime() 0 4 1
A getRankingSystem() 0 4 1
A isCurrent() 0 4 1
A setCurrent() 0 4 1
A setLastEntryTime() 0 4 1
A setRankingSystem() 0 8 2
A init() 0 6 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\Common\Collections\ArrayCollection;
14
use Doctrine\Common\Collections\Collection;
15
use Doctrine\ORM\Mapping as ORM;
16
use Tfboe\FmLib\Entity\Helpers\UUIDEntity;
17
use Tfboe\FmLib\Entity\RankingSystemInterface;
18
use Tfboe\FmLib\Entity\RankingSystemListEntryInterface;
19
20
21
/**
22
 * Trait RankingSystemList
23
 * @package Tfboe\FmLib\Entity\Traits
24
 */
25
trait RankingSystemList
26
{
27
  use UUIDEntity;
28
29
//<editor-fold desc="Fields">
30
  /**
31
   * @ORM\ManyToOne(targetEntity="\Tfboe\FmLib\Entity\RankingSystemInterface", inversedBy="lists")
32
   * @var RankingSystemInterface
33
   */
34
  private $rankingSystem;
35
  /**
36
   * @ORM\Column(type="boolean")
37
   * @var bool
38
   */
39
  private $current;
40
  /**
41
   * @ORM\Column(type="datetime")
42
   * @var \DateTime
43
   */
44
  private $lastEntryTime;
45
46
  /**
47
   * @ORM\OneToMany(targetEntity="\Tfboe\FmLib\Entity\RankingSystemListEntryInterface", mappedBy="rankingSystemList",
48
   *   indexBy="player_id")
49
   * @var RankingSystemListEntryInterface[]|Collection
50
   */
51
  private $entries;
52
//</editor-fold desc="Fields">
53
54
//<editor-fold desc="Constructor">
55
//</editor-fold desc="Constructor">
56
57
//<editor-fold desc="Public Methods">
58
  /**
59
   * @return RankingSystemListEntryInterface[]|Collection
60
   */
61
  public function getEntries(): Collection
62
  {
63
    return $this->entries;
64
  }
65
66
  /**
67
   * @return \DateTime
68
   */
69
  public function getLastEntryTime(): \DateTime
70
  {
71
    return $this->lastEntryTime;
72
  }
73
74
  /**
75
   * @return RankingSystemInterface
76
   */
77
  public function getRankingSystem(): RankingSystemInterface
78
  {
79
    return $this->rankingSystem;
80
  }
81
82
  /**
83
   * @return bool
84
   */
85
  public function isCurrent(): bool
86
  {
87
    return $this->current;
88
  }
89
90
  /**
91
   * @param bool $current
92
   */
93
  public function setCurrent(bool $current)
94
  {
95
    $this->current = $current;
96
  }
97
98
  /**
99
   * @param \DateTime $lastEntryTime
100
   */
101
  public function setLastEntryTime(\DateTime $lastEntryTime)
102
  {
103
    $this->lastEntryTime = $lastEntryTime;
104
  }
105
106
  /**
107
   * @param RankingSystemInterface $rankingSystem
108
   */
109
  public function setRankingSystem(RankingSystemInterface $rankingSystem)
110
  {
111
    if ($this->rankingSystem !== null) {
112
      $this->rankingSystem->getLists()->remove($this->getId());
113
    }
114
    $this->rankingSystem = $rankingSystem;
115
    $rankingSystem->getLists()->set($this->getId(), $this);
116
  }
117
//</editor-fold desc="Public Methods">
118
119
//<editor-fold desc="Protected Final Methods">
120
  /**
121
   * RankingSystemList init
122
   */
123
  protected final function init()
124
  {
125
    $this->lastEntryTime = new \DateTime("2000-01-01");
126
    $this->current = false;
127
    $this->entries = new ArrayCollection();
128
  }
129
//</editor-fold desc="Protected Final Methods">
130
}