Passed
Pull Request — develop (#54)
by Verlhac
04:40
created

PlayerChart::setIdProof()   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
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\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 integer
53
     *
54
     * @ORM\Column(name="idStatus", type="integer", nullable=false)
55
     */
56
    private $idStatus;
57
58
    /**
59
     * @var boolean
60
     *
61
     * @ORM\Column(name="isTopScore", type="boolean", nullable=false)
62
     */
63
    private $topScore = false;
64
65
    /**
66
     * @var \DateTime
67
     *
68
     * @ORM\Column(name="dateModif", type="datetime", nullable=false)
69
     */
70
    private $dateModif;
71
72
    /**
73
     * @var \DateTime
74
     *
75
     * @ORM\Column(name="dateInvestigation", type="date", nullable=true)
76
     */
77
    private $dateInvestigation;
78
79
    /**
80
     * @var Chart
81
     *
82
     * @ORM\ManyToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Chart", inversedBy="playerCharts")
83
     * @ORM\JoinColumns({
84
     *   @ORM\JoinColumn(name="idChart", referencedColumnName="id")
85
     * })
86
     */
87
    private $chart;
88
89
    /**
90
     * @var Proof
91
     *
92
     * @ORM\ManyToOne(targetEntity="VideoGamesRecords\ProofBundle\Entity\Proof")
93
     * @ORM\JoinColumns({
94
     *   @ORM\JoinColumn(name="idProof", referencedColumnName="idProof")
95
     * })
96
     */
97
    private $proof;
98
99
    /**
100
     * @var PlayerChartStatus
101
     *
102
     * @ORM\ManyToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\PlayerChartStatus")
103
     * @ORM\JoinColumns({
104
     *   @ORM\JoinColumn(name="idStatus", referencedColumnName="idStatus")
105
     * })
106
     */
107
    private $status;
108
109
    /**
110
     * @var Platform
111
     *
112
     * @ORM\ManyToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Platform")
113
     * @ORM\JoinColumns({
114
     *   @ORM\JoinColumn(name="idPlatform", referencedColumnName="idPlatform")
115
     * })
116
     */
117
    private $platform;
118
119
    /**
120
     * Set idPlayerChart
121
     *
122
     * @param integer $idPlayerChart
123
     * @return PlayerChart
124
     */
125
    public function setIdPlayerChart($idPlayerChart)
126
    {
127
        $this->idPlayerChart = $idPlayerChart;
128
        return $this;
129
    }
130
131
    /**
132
     * Get idPlayerChart
133
     *
134
     * @return integer
135
     */
136
    public function getIdPlayerChart()
137
    {
138
        return $this->idPlayerChart;
139
    }
140
141
    /**
142
     * Set rank
143
     *
144
     * @param integer $rank
145
     * @return PlayerChart
146
     */
147
    public function setRank($rank)
148
    {
149
        $this->rank = $rank;
150
        return $this;
151
    }
152
153
    /**
154
     * Get rank
155
     *
156
     * @return integer
157
     */
158
    public function getRank()
159
    {
160
        return $this->rank;
161
    }
162
163
    /**
164
     * Set nbEqual
165
     *
166
     * @param integer $nbEqual
167
     * @return PlayerChart
168
     */
169
    public function setNbEqual($nbEqual)
170
    {
171
        $this->nbEqual = $nbEqual;
172
        return $this;
173
    }
174
175
    /**
176
     * Get nbEqual
177
     *
178
     * @return integer
179
     */
180
    public function getNbEqual()
181
    {
182
        return $this->nbEqual;
183
    }
184
185
    /**
186
     * Set pointChart
187
     *
188
     * @param float $pointChart
189
     * @return PlayerChart
190
     */
191
    public function setPointChart($pointChart)
192
    {
193
        $this->pointChart = $pointChart;
194
        return $this;
195
    }
196
197
    /**
198
     * Get pointChart
199
     *
200
     * @return float
201
     */
202
    public function getPointChart()
203
    {
204
        return $this->pointChart;
205
    }
206
207
    /**
208
     * Set idStatus
209
     *
210
     * @param integer $idStatus
211
     * @return PlayerChart
212
     */
213
    public function setIdStatus($idStatus)
214
    {
215
        $this->idStatus = $idStatus;
216
        return $this;
217
    }
218
219
    /**
220
     * Set topScore
221
     *
222
     * @param bool $topScore
223
     *
224
     * @return PlayerChart
225
     */
226
    public function setTopScore($topScore)
227
    {
228
        $this->topScore = $topScore;
229
        return $this;
230
    }
231
232
    /**
233
     * Get topScore
234
     *
235
     * @return bool
236
     */
237
    public function isTopScore()
238
    {
239
        return $this->topScore;
240
    }
241
242
    /**
243
     * Set dateModif
244
     *
245
     * @param \DateTime $dateModif
246
     * @return PlayerChart
247
     */
248
    public function setDateModif($dateModif)
249
    {
250
        $this->dateModif = $dateModif;
251
        return $this;
252
    }
253
254
    /**
255
     * Get dateModif
256
     *
257
     * @return \DateTime
258
     */
259
    public function getDateModif()
260
    {
261
        return $this->dateModif;
262
    }
263
264
    /**
265
     * Set dateInvestigation
266
     *
267
     * @param \DateTime $dateInvestigation
268
     * @return PlayerChart
269
     */
270
    public function setDateInvestigation($dateInvestigation)
271
    {
272
        $this->dateInvestigation = $dateInvestigation;
273
        return $this;
274
    }
275
276
    /**
277
     * Get dateInvestigation
278
     *
279
     * @return \DateTime
280
     */
281
    public function getDateInvestigation()
282
    {
283
        return $this->dateInvestigation;
284
    }
285
286
    /**
287
     * Set chart
288
     *
289
     * @param Chart $chart
290
     * @return PlayerChart
291
     */
292
    public function setChart(Chart $chart = null)
293
    {
294
        $this->chart = $chart;
295
296
        return $this;
297
    }
298
299
    /**
300
     * Get chart
301
     *
302
     * @return Chart
303
     */
304
    public function getChart()
305
    {
306
        return $this->chart;
307
    }
308
309
    /**
310
     * Set proof
311
     *
312
     * @param Proof $proof
313
     * @return PlayerChart
314
     */
315
    public function setProof(Proof $proof = null)
316
    {
317
        $this->proof = $proof;
318
319
        return $this;
320
    }
321
322
    /**
323
     * Get proof
324
     *
325
     * @return Proof
326
     */
327
    public function getProof()
328
    {
329
        return $this->proof;
330
    }
331
332
333
    /**
334
     * Set platform
335
     *
336
     * @param Platform $platform
337
     * @return PlayerChart
338
     */
339
    public function setPlatform(Platform $platform = null)
340
    {
341
        $this->platform = $platform;
342
        return $this;
343
    }
344
345
    /**
346
     * Get platform
347
     *
348
     * @return Platform
349
     */
350
    public function getPlatform()
351
    {
352
        return $this->platform;
353
    }
354
355
356
    /**
357
     * Set status
358
     *
359
     * @param PlayerChartStatus $status
360
     * @return PlayerChart
361
     */
362
    public function setStatus(PlayerChartStatus $status = null)
363
    {
364
        $this->status = $status;
365
        if (null !== $status) {
366
            $this->setIdStatus($status->getIdStatus());
367
        }
368
        return $this;
369
    }
370
371
    /**
372
     * Get status
373
     *
374
     * @return PlayerChartStatus
375
     */
376
    public function getStatus()
377
    {
378
        return $this->status;
379
    }
380
381
    /**
382
     * @ORM\PreUpdate()
383
     */
384
    public function preUpdate()
385
    {
386
        if ($this->getRank() === 1) {
387
            $this->setTopScore(true);
388
        } else {
389
            $this->setTopScore(false);
390
        }
391
        if ((null === $this->getDateInvestigation()) && (PlayerChartStatus::ID_STATUS_INVESTIGATION === $this->getStatus()->getIdStatus())) {
392
            $this->setDateInvestigation(new \DateTime());
393
        }
394
        if ((null !== $this->getDateInvestigation()) && (PlayerChartStatus::ID_STATUS_PROOVED === $this->getStatus()->getIdStatus())) {
395
            $this->setDateInvestigation(null);
396
        }
397
        if ((null !== $this->getDateInvestigation()) && (PlayerChartStatus::ID_STATUS_NOT_PROOVED === $this->getStatus()->getIdStatus())) {
398
            $this->setDateInvestigation(null);
399
        }
400
    }
401
}
402