Test Failed
Pull Request — develop (#72)
by
unknown
03:19
created

PlayerChart::removeLib()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace VideoGamesRecords\CoreBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use VideoGamesRecords\ProofBundle\Entity\Proof;
0 ignored issues
show
Bug introduced by
The type VideoGamesRecords\ProofBundle\Entity\Proof 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...
7
use Knp\DoctrineBehaviors\Model\Timestampable\Timestampable;
8
9
/**
10
 * PlayerChart
11
 *
12
 * @ORM\Table(name="vgr_player_chart", indexes={@ORM\Index(name="idxIdChart", columns={"idChart"}), @ORM\Index(name="idxIdPlayer", columns={"idPlayer"})})
13
 * @ORM\Entity(repositoryClass="VideoGamesRecords\CoreBundle\Repository\PlayerChartRepository")
14
 * @ORM\HasLifecycleCallbacks()
15
 */
16
class PlayerChart
17
{
18
    use Timestampable;
19
    use \VideoGamesRecords\CoreBundle\Model\Player;
20
21
    /**
22
     * @var integer
23
     *
24
     * @ORM\Column(name="idPlayerChart", type="integer")
25
     * @ORM\Id
26
     * @ORM\GeneratedValue(strategy="IDENTITY")
27
     */
28
    private $idPlayerChart;
29
30
    /**
31
     * @var integer
32
     *
33
     * @ORM\Column(name="rank", type="integer", nullable=true)
34
     */
35
    private $rank;
36
37
    /**
38
     * @var integer
39
     *
40
     * @ORM\Column(name="nbEqual", type="integer", nullable=false)
41
     */
42
    private $nbEqual = 0;
43
44
    /**
45
     * @var integer
46
     *
47
     * @ORM\Column(name="pointChart", type="integer", nullable=false)
48
     */
49
    private $pointChart = 0;
50
51
    /**
52
     * @var boolean
53
     *
54
     * @ORM\Column(name="isTopScore", type="boolean", nullable=false)
55
     */
56
    private $topScore = false;
57
58
    /**
59
     * @var \DateTime
60
     *
61
     * @ORM\Column(name="dateModif", type="datetime", nullable=false)
62
     */
63
    private $dateModif;
64
65
    /**
66
     * @var \DateTime
67
     *
68
     * @ORM\Column(name="dateInvestigation", type="date", nullable=true)
69
     */
70
    private $dateInvestigation;
71
72
    /**
73
     * @var Chart
74
     *
75
     * @ORM\ManyToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Chart", inversedBy="playerCharts")
76
     * @ORM\JoinColumns({
77
     *   @ORM\JoinColumn(name="idChart", referencedColumnName="id", nullable=false)
78
     * })
79
     */
80
    private $chart;
81
82
    /**
83
     * @var Proof
84
     *
85
     * @ORM\ManyToOne(targetEntity="VideoGamesRecords\ProofBundle\Entity\Proof")
86
     * @ORM\JoinColumns({
87
     *   @ORM\JoinColumn(name="idProof", referencedColumnName="idProof")
88
     * })
89
     */
90
    private $proof;
91
92
    /**
93
     * @var PlayerChartStatus
94
     *
95
     * @ORM\ManyToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\PlayerChartStatus")
96
     * @ORM\JoinColumns({
97
     *   @ORM\JoinColumn(name="idStatus", referencedColumnName="idStatus", nullable=false)
98
     * })
99
     */
100
    private $status;
101
102
    /**
103
     * @var Platform
104
     *
105
     * @ORM\ManyToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Platform")
106
     * @ORM\JoinColumns({
107
     *   @ORM\JoinColumn(name="idPlatform", referencedColumnName="idPlatform")
108
     * })
109
     */
110
    private $platform;
111
112
    /**
113
     * @var ArrayCollection|\VideoGamesRecords\CoreBundle\Entity\PlayerChartLib[]
114
     *
115
     * @ORM\OneToMany(targetEntity="VideoGamesRecords\CoreBundle\Entity\PlayerChartLib", mappedBy="playerChart", cascade={"persist", "remove"}, orphanRemoval=true)
116
     */
117
    private $libs;
118
119
    /**
120
     * Constructor
121
     */
122
    public function __construct()
123
    {
124
        $this->libs = new ArrayCollection();
0 ignored issues
show
Bug introduced by
The type VideoGamesRecords\CoreBu...\Entity\ArrayCollection 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...
125
    }
126
127
    /**
128
     * Set idPlayerChart
129
     *
130
     * @param integer $idPlayerChart
131
     * @return PlayerChart
132
     */
133
    public function setIdPlayerChart($idPlayerChart)
134
    {
135
        $this->idPlayerChart = $idPlayerChart;
136
        return $this;
137
    }
138
139
    /**
140
     * Get idPlayerChart
141
     *
142
     * @return integer
143
     */
144
    public function getIdPlayerChart()
145
    {
146
        return $this->idPlayerChart;
147
    }
148
149
    /**
150
     * Set rank
151
     *
152
     * @param integer $rank
153
     * @return PlayerChart
154
     */
155
    public function setRank($rank)
156
    {
157
        $this->rank = $rank;
158
        return $this;
159
    }
160
161
    /**
162
     * Get rank
163
     *
164
     * @return integer
165
     */
166
    public function getRank()
167
    {
168
        return $this->rank;
169
    }
170
171
    /**
172
     * Set nbEqual
173
     *
174
     * @param integer $nbEqual
175
     * @return PlayerChart
176
     */
177
    public function setNbEqual($nbEqual)
178
    {
179
        $this->nbEqual = $nbEqual;
180
        return $this;
181
    }
182
183
    /**
184
     * Get nbEqual
185
     *
186
     * @return integer
187
     */
188
    public function getNbEqual()
189
    {
190
        return $this->nbEqual;
191
    }
192
193
    /**
194
     * Set pointChart
195
     *
196
     * @param float $pointChart
197
     * @return PlayerChart
198
     */
199
    public function setPointChart($pointChart)
200
    {
201
        $this->pointChart = $pointChart;
202
        return $this;
203
    }
204
205
    /**
206
     * Get pointChart
207
     *
208
     * @return float
209
     */
210
    public function getPointChart()
211
    {
212
        return $this->pointChart;
213
    }
214
215
    /**
216
     * Set topScore
217
     *
218
     * @param bool $topScore
219
     *
220
     * @return PlayerChart
221
     */
222
    public function setTopScore($topScore)
223
    {
224
        $this->topScore = $topScore;
225
        return $this;
226
    }
227
228
    /**
229
     * Get topScore
230
     *
231
     * @return bool
232
     */
233
    public function isTopScore()
234
    {
235
        return $this->topScore;
236
    }
237
238
    /**
239
     * Set dateModif
240
     *
241
     * @param \DateTime $dateModif
242
     * @return PlayerChart
243
     */
244
    public function setDateModif($dateModif)
245
    {
246
        $this->dateModif = $dateModif;
247
        return $this;
248
    }
249
250
    /**
251
     * Get dateModif
252
     *
253
     * @return \DateTime
254
     */
255
    public function getDateModif()
256
    {
257
        return $this->dateModif;
258
    }
259
260
    /**
261
     * Set dateInvestigation
262
     *
263
     * @param \DateTime $dateInvestigation
264
     * @return PlayerChart
265
     */
266
    public function setDateInvestigation($dateInvestigation)
267
    {
268
        $this->dateInvestigation = $dateInvestigation;
269
        return $this;
270
    }
271
272
    /**
273
     * Get dateInvestigation
274
     *
275
     * @return \DateTime
276
     */
277
    public function getDateInvestigation()
278
    {
279
        return $this->dateInvestigation;
280
    }
281
282
    /**
283
     * Set chart
284
     *
285
     * @param Chart $chart
286
     * @return PlayerChart
287
     */
288
    public function setChart(Chart $chart = null)
289
    {
290
        $this->chart = $chart;
291
292
        return $this;
293
    }
294
295
    /**
296
     * Get chart
297
     *
298
     * @return Chart
299
     */
300
    public function getChart()
301
    {
302
        return $this->chart;
303
    }
304
305
    /**
306
     * Set proof
307
     *
308
     * @param Proof $proof
309
     * @return PlayerChart
310
     */
311
    public function setProof(Proof $proof = null)
312
    {
313
        $this->proof = $proof;
314
315
        return $this;
316
    }
317
318
    /**
319
     * Get proof
320
     *
321
     * @return Proof
322
     */
323
    public function getProof()
324
    {
325
        return $this->proof;
326
    }
327
328
329
    /**
330
     * Set platform
331
     *
332
     * @param Platform $platform
333
     * @return PlayerChart
334
     */
335
    public function setPlatform(Platform $platform = null)
336
    {
337
        $this->platform = $platform;
338
        return $this;
339
    }
340
341
    /**
342
     * Get platform
343
     *
344
     * @return Platform
345
     */
346
    public function getPlatform()
347
    {
348
        return $this->platform;
349
    }
350
351
352
    /**
353
     * Set status
354
     *
355
     * @param PlayerChartStatus $status
356
     * @return PlayerChart
357
     */
358
    public function setStatus(PlayerChartStatus $status = null)
359
    {
360
        $this->status = $status;
361
362
        return $this;
363
    }
364
365
    /**
366
     * Get status
367
     *
368
     * @return PlayerChartStatus
369
     */
370
    public function getStatus()
371
    {
372
        return $this->status;
373
    }
374
375
    /**
376
     * @param PlayerChartLib $lib
377
     * @return $this
378
     */
379
    public function addLib(PlayerChartLib $lib)
380
    {
381
        $lib->setPlayerChart($this);
382
        $this->libs[] = $lib;
383
        return $this;
384
    }
385
386
    /**
387
     * @param PlayerChartLib $lib
388
     */
389
    public function removeLib(PlayerChartLib $lib)
390
    {
391
        $this->libs->removeElement($lib);
392
    }
393
394
    /**
395
     * @return ArrayCollection|\VideoGamesRecords\CoreBundle\Entity\PlayerChartLib[]
396
     */
397
    public function getLibs()
398
    {
399
        return $this->libs;
400
    }
401
402
    /**
403
     * @ORM\PreUpdate()
404
     */
405
    public function preUpdate()
406
    {
407
        $this->setTopScore(false);
408
        if ($this->getRank() === 1) {
409
            $this->setTopScore(true);
410
        }
411
412
        if (null === $this->getDateInvestigation() && PlayerChartStatus::ID_STATUS_INVESTIGATION === $this->getStatus()->getIdStatus()) {
413
            $this->setDateInvestigation(new \DateTime());
414
        }
415
        if (null !== $this->getDateInvestigation() && in_array($this->getStatus()->getIdStatus(), [PlayerChartStatus::ID_STATUS_PROOVED, PlayerChartStatus::ID_STATUS_NOT_PROOVED], true)) {
416
            $this->setDateInvestigation(null);
417
        }
418
    }
419
}
420