Completed
Push — master ( e08508...e2d78b )
by Benedikt
07:44
created

RankingSystem::getOpenSyncFromInProcess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
cc 1
nc 1
nop 0
rs 10
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Created by PhpStorm.
5
 * User: benedikt
6
 * Date: 1/2/18
7
 * Time: 8:47 PM
8
 */
9
10
namespace Tfboe\FmLib\Entity\Traits;
11
12
use Doctrine\Common\Collections\ArrayCollection;
13
use Doctrine\Common\Collections\Collection;
14
use Doctrine\ORM\Mapping as ORM;
15
use Tfboe\FmLib\Entity\Helpers\AutomaticInstanceGeneration;
16
use Tfboe\FmLib\Entity\Helpers\NameEntity;
17
use Tfboe\FmLib\Entity\Helpers\SubClassData;
18
use Tfboe\FmLib\Entity\Helpers\TimestampableEntity;
19
use Tfboe\FmLib\Entity\Helpers\UUIDEntity;
20
use Tfboe\FmLib\Entity\RankingSystemListInterface;
21
use Tfboe\FmLib\Entity\TournamentInterface;
22
use Tfboe\FmLib\Exceptions\ValueNotValid;
23
use Tfboe\FmLib\Helpers\Level;
24
25
/**
26
 * Trait RankingSystem
27
 * @package Tfboe\FmLib\Entity\Traits
28
 */
29
trait RankingSystem
30
{
31
  use SubClassData;
32
  use TimestampableEntity;
33
  use UUIDEntity;
34
  use NameEntity;
35
36
  //<editor-fold desc="Fields">
37
38
  /**
39
   * @ORM\Column(type="string")
40
   *
41
   * @var string
42
   */
43
  private $serviceName;
44
  /**
45
   * @ORM\Column(type="smallint", nullable=true)
46
   * @var int|null
47
   */
48
  private $defaultForLevel;
49
50
  /**
51
   * @ORM\Column(type="integer")
52
   * @var int
53
   */
54
  private $generationInterval;
55
56
  /**
57
   * @ORM\ManyToMany(
58
   *     targetEntity="\Tfboe\FmLib\Entity\Helpers\TournamentHierarchyEntity",
59
   *     mappedBy="rankingSystems",
60
   *     indexBy="id"
61
   * )
62
   * @ORM\JoinTable(name="relation__tournament_ranking_systems")
63
   * @var Collection|TournamentInterface[]
64
   */
65
  private $hierarchyEntries;
66
  /**
67
   * @ORM\Column(type="datetime", nullable=true)
68
   * @var \DateTime|null
69
   */
70
  private $openSyncFrom;
71
72
  /**
73
   * @ORM\OneToMany(targetEntity="\Tfboe\FmLib\Entity\RankingSystemListInterface", mappedBy="rankingSystem",
74
   *   indexBy="id")
75
   * @var Collection|RankingSystemListInterface[]
76
   */
77
  private $lists;
78
//</editor-fold desc="Fields">
79
80
//<editor-fold desc="Constructor">
81
//</editor-fold desc="Constructor">
82
83
//<editor-fold desc="Public Methods">
84
  /**
85
   * @return int|null
86
   */
87
  public function getDefaultForLevel(): ?int
88
  {
89
    return $this->defaultForLevel;
90
  }
91
92
  /**
93
   * @return int
94
   */
95
  public function getGenerationInterval(): int
96
  {
97
    return $this->generationInterval;
98
  }
99
100
  /**
101
   * @return TournamentInterface[]|Collection
102
   */
103
  public function getHierarchyEntries()
104
  {
105
    return $this->hierarchyEntries;
106
  }
107
108
  /**
109
   * @return RankingSystemListInterface[]|Collection
110
   */
111
  public function getLists(): Collection
112
  {
113
    return $this->lists;
114
  }
115
116
  /**
117
   * @return \DateTime|null
118
   */
119
  public function getOpenSyncFrom(): ?\DateTime
120
  {
121
    return $this->openSyncFrom;
122
  }
123
124
  /**
125
   * @return string
126
   */
127
  public function getServiceName(): string
128
  {
129
    return $this->serviceName;
130
  }
131
132
  /**
133
   * @param int|null $defaultForLevel
134
   * @throws ValueNotValid
135
   */
136
  public function setDefaultForLevel(?int $defaultForLevel)
137
  {
138
    if ($defaultForLevel !== null) {
139
      Level::ensureValidValue($defaultForLevel);
140
    }
141
    $this->defaultForLevel = $defaultForLevel;
142
  }
143
144
  /**
145
   * @param int $generationInterval
146
   * @throws \Tfboe\FmLib\Exceptions\ValueNotValid
147
   */
148
  public function setGenerationInterval(int $generationInterval)
149
  {
150
    AutomaticInstanceGeneration::ensureValidValue($generationInterval);
151
    $this->generationInterval = $generationInterval;
152
  }
153
154
  /**
155
   * @param \DateTime|null $openSyncFrom
156
   */
157
  public function setOpenSyncFrom(?\DateTime $openSyncFrom)
158
  {
159
    $this->openSyncFrom = $openSyncFrom;
160
  }
161
162
  /**
163
   * @param string $serviceName
164
   */
165
  public function setServiceName(string $serviceName)
166
  {
167
    $this->serviceName = $serviceName;
168
  }
169
//</editor-fold desc="Public Methods">
170
171
//<editor-fold desc="Protected Final Methods">
172
  /**
173
   * RankingSystem init
174
   * @param string[] $keys the keys of the subclass properties
175
   */
176
  protected final function init(array $keys)
177
  {
178
    $this->initSubClassData($keys);
179
    $this->generationInterval = AutomaticInstanceGeneration::OFF;
180
    $this->defaultForLevel = null;
181
    $this->openSyncFrom = null;
182
    $this->lists = new ArrayCollection();
183
    $this->hierarchyEntries = new ArrayCollection();
184
  }
185
//</editor-fold desc="Protected Final Methods">
186
}