Passed
Push — develop ( e8f487...e4693f )
by
unknown
01:12 queued 10s
created

PlayerChart::setPointChart()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

413
        $this->setStatus($entityManager->/** @scrutinizer ignore-call */ getReference('VideoGamesRecords\CoreBundle\Entity\PlayerChartStatus', 1));
Loading history...
414
        $this->setDateModif(new \DateTime());
415
    }
416
417
    /**
418
     * @ORM\PreUpdate()
419
     */
420
    public function preUpdate()
421
    {
422
        $this->setTopScore(false);
423
        if ($this->getRank() === 1) {
424
            $this->setTopScore(true);
425
        }
426
427
        if (null === $this->getDateInvestigation() && PlayerChartStatus::ID_STATUS_INVESTIGATION === $this->getStatus()->getIdStatus()) {
428
            $this->setDateInvestigation(new \DateTime());
429
        }
430
        if (null !== $this->getDateInvestigation() && in_array($this->getStatus()->getIdStatus(), [PlayerChartStatus::ID_STATUS_PROOVED, PlayerChartStatus::ID_STATUS_NOT_PROOVED], true)) {
431
            $this->setDateInvestigation(null);
432
        }
433
434
        /*$playerChart->setStatus($em->getReference('VideoGamesRecords\CoreBundle\Entity\PlayerChartStatus', 1));
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
435
        $playerChart->setDateModif(new \DateTime());*/
436
    }
437
}
438