1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace eXpansion\Bundle\MxKarma\Entity; |
4
|
|
|
|
5
|
|
|
use ArrayObject; |
6
|
|
|
|
7
|
|
|
class MxRating |
8
|
|
|
{ |
9
|
|
|
/** @var int */ |
10
|
|
|
protected $voteCount; |
11
|
|
|
|
12
|
|
|
/** @var int */ |
13
|
|
|
protected $voteAverage; |
14
|
|
|
|
15
|
|
|
/** @var int */ |
16
|
|
|
protected $modeVoteCount; |
17
|
|
|
|
18
|
|
|
/** @var int */ |
19
|
|
|
protected $modeVoteAverage; |
20
|
|
|
|
21
|
|
|
/** @var mxVote[] */ |
22
|
|
|
protected $votes = array(); |
23
|
|
|
|
24
|
|
|
public function append($object) |
25
|
|
|
{ |
26
|
|
|
if (!is_object($object)) { |
27
|
|
|
throw new \Exception("MXVote constructor got non object"); |
28
|
|
|
} |
29
|
|
|
$this->voteCount = $object->votecount; |
30
|
|
|
$this->voteAverage = $object->voteaverage; |
31
|
|
|
if ($object->modevotecount != -1) { |
32
|
|
|
$this->modeVoteCount = $object->modevotecount; |
33
|
|
|
} |
34
|
|
|
if ($object->modevoteaverage != -1) { |
35
|
|
|
$this->modeVoteAverage = $object->modevoteaverage; |
36
|
|
|
} |
37
|
|
|
if (is_array($object->votes)) { |
38
|
|
|
foreach ($object->votes as $vote) { |
39
|
|
|
$this->votes[$vote->login] = new MxVote($vote); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return string |
46
|
|
|
*/ |
47
|
|
|
public function getVotes() |
48
|
|
|
{ |
49
|
|
|
return $this->votes; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param MxVote[] $votes |
54
|
|
|
* @return $this |
55
|
|
|
*/ |
56
|
|
|
public function setVotes($votes) |
57
|
|
|
{ |
58
|
|
|
$this->votes = $votes; |
59
|
|
|
|
60
|
|
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return int |
65
|
|
|
*/ |
66
|
|
|
public function getModeVoteAverage() |
67
|
|
|
{ |
68
|
|
|
return $this->modeVoteAverage; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param int $modeVoteAverage |
73
|
|
|
* @return $this |
74
|
|
|
*/ |
75
|
|
|
public function setModeVoteAverage($modeVoteAverage) |
76
|
|
|
{ |
77
|
|
|
$this->modeVoteAverage = $modeVoteAverage; |
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return int |
84
|
|
|
*/ |
85
|
|
|
public function getModeVoteCount() |
86
|
|
|
{ |
87
|
|
|
return $this->modeVoteCount; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param int $modeVoteCount |
92
|
|
|
* @return $this |
93
|
|
|
*/ |
94
|
|
|
public function setModeVoteCount($modeVoteCount) |
95
|
|
|
{ |
96
|
|
|
$this->modeVoteCount = $modeVoteCount; |
97
|
|
|
|
98
|
|
|
return $this; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @return int |
103
|
|
|
*/ |
104
|
|
|
public function getVoteAverage() |
105
|
|
|
{ |
106
|
|
|
return $this->voteAverage; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param int $voteAverage |
111
|
|
|
* @return $this |
112
|
|
|
*/ |
113
|
|
|
public function setVoteAverage($voteAverage) |
114
|
|
|
{ |
115
|
|
|
$this->voteAverage = $voteAverage; |
116
|
|
|
|
117
|
|
|
return $this; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return int |
122
|
|
|
*/ |
123
|
|
|
public function getVoteCount() |
124
|
|
|
{ |
125
|
|
|
return $this->voteCount; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param int $voteCount |
130
|
|
|
* @return $this |
131
|
|
|
*/ |
132
|
|
|
public function setVoteCount($voteCount) |
133
|
|
|
{ |
134
|
|
|
$this->voteCount = $voteCount; |
135
|
|
|
|
136
|
|
|
return $this; |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|