Score::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
namespace NekoAPI\Component\Entity;
4
5
/**
6
 * Class Score
7
 *
8
 * @package NekoAPI\Component\Entity
9
 * @author  Aurimas Niekis <[email protected]>
10
 */
11
class Score extends BaseEntity
12
{
13
    /**
14
     * @var float
15
     */
16
    private $score;
17
18
    /**
19
     * @var int
20
     */
21
    private $scoredBy;
22
23 2
    public function __construct(?float $score, ?int $scoredBy)
24
    {
25 2
        $this->score    = $score;
26 2
        $this->scoredBy = $scoredBy;
27 2
    }
28
29
    /**
30
     * @return float
31
     */
32 2
    public function getScore(): ?float
33
    {
34 2
        return $this->score;
35
    }
36
37
    /**
38
     * @param float $score
39
     *
40
     * @return Score
41
     */
42 1
    public function setScore(float $score): Score
43
    {
44 1
        $this->score = $score;
45
46 1
        return $this;
47
    }
48
49
    /**
50
     * @return int
51
     */
52 2
    public function getScoredBy(): ?int
53
    {
54 2
        return $this->scoredBy;
55
    }
56
57
    /**
58
     * @param int $scoredBy
59
     *
60
     * @return Score
61
     */
62 1
    public function setScoredBy(int $scoredBy): Score
63
    {
64 1
        $this->scoredBy = $scoredBy;
65
66 1
        return $this;
67
    }
68
69
    /**
70
     * @inheritDoc
71
     */
72 1
    public function jsonSerialize(): array
73
    {
74
        return [
75 1
            'score'     => $this->getScore(),
76 1
            'scored_by' => $this->getScoredBy(),
77
        ];
78
    }
79
}