Completed
Pull Request — master (#80)
by De Cramer
02:23
created

MxRating::append()   B

Complexity

Conditions 6
Paths 13

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 0
cts 19
cp 0
rs 8.8571
c 0
b 0
f 0
cc 6
eloc 12
nc 13
nop 1
crap 42
1
<?php
2
3
namespace eXpansion\Bundle\MxKarma\Entity;
4
5
class MxRating
6
{
7
    /** @var int */
8
    protected $voteCount;
9
10
    /** @var int */
11
    protected $voteAverage;
12
13
    /** @var int */
14
    protected $modeVoteCount;
15
16
    /** @var int */
17
    protected $modeVoteAverage;
18
19
    /** @var string[login, number] */
20
    protected $votes = array();
21
22
    public function append($object)
23
    {
24
        if (!is_object($object)) {
25
            throw new \Exception("MXVote constructor got non object", 1, null);
26
        }
27
        $this->voteCount = $object->votecount;
28
        $this->voteAverage = $object->voteaverage;
29
        if ($object->modevotecount != -1) {
30
            $this->modeVoteCount = $object->modevotecount;
31
        }
32
        if ($object->modevoteaverage != -1) {
33
            $this->modeVoteAverage = $object->modevoteaverage;
34
        }
35
        if (is_array($object->votes)) {
36
            foreach ($object->votes as $vote) {
37
                $this->votes[] = $vote;
38
            }
39
        }
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function getVotes()
46
    {
47
        return $this->votes;
48
    }
49
50
    /**
51
     * @param string $votes
52
     */
53
    public function setVotes($votes)
54
    {
55
        $this->votes = $votes;
0 ignored issues
show
Documentation Bug introduced by
It seems like $votes of type string is incompatible with the declared type array of property $votes.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
56
    }
57
58
    /**
59
     * @return int
60
     */
61
    public function getModeVoteAverage()
62
    {
63
        return $this->modeVoteAverage;
64
    }
65
66
    /**
67
     * @param int $modeVoteAverage
68
     */
69
    public function setModeVoteAverage($modeVoteAverage)
70
    {
71
        $this->modeVoteAverage = $modeVoteAverage;
72
    }
73
74
    /**
75
     * @return int
76
     */
77
    public function getModeVoteCount()
78
    {
79
        return $this->modeVoteCount;
80
    }
81
82
    /**
83
     * @param int $modeVoteCount
84
     */
85
    public function setModeVoteCount($modeVoteCount)
86
    {
87
        $this->modeVoteCount = $modeVoteCount;
88
    }
89
90
    /**
91
     * @return int
92
     */
93
    public function getVoteAverage()
94
    {
95
        return $this->voteAverage;
96
    }
97
98
    /**
99
     * @param int $voteAverage
100
     */
101
    public function setVoteAverage($voteAverage)
102
    {
103
        $this->voteAverage = $voteAverage;
104
    }
105
106
    /**
107
     * @return int
108
     */
109
    public function getVoteCount()
110
    {
111
        return $this->voteCount;
112
    }
113
114
    /**
115
     * @param int $voteCount
116
     */
117
    public function setVoteCount($voteCount)
118
    {
119
        $this->voteCount = $voteCount;
120
    }
121
}
122