1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the MsalsasVotingBundle package. |
5
|
|
|
* |
6
|
|
|
* (c) Manolo Salsas |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Msalsas\VotingBundle\Entity; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
class ReferenceVotes |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var integer |
19
|
|
|
*/ |
20
|
|
|
protected $reference; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var integer |
24
|
|
|
*/ |
25
|
|
|
protected $positiveVotes = 0; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var integer |
29
|
|
|
*/ |
30
|
|
|
protected $negativeVotes = 0; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var integer |
34
|
|
|
*/ |
35
|
|
|
protected $userVotes = 0; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var integer |
39
|
|
|
*/ |
40
|
|
|
protected $anonymousVotes = 0; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var boolean |
44
|
|
|
*/ |
45
|
|
|
protected $published = false; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @return int |
49
|
|
|
*/ |
50
|
4 |
|
public function getReference(): int |
51
|
|
|
{ |
52
|
4 |
|
return $this->reference; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param int $reference |
57
|
|
|
*/ |
58
|
8 |
|
public function setReference(int $reference) |
59
|
|
|
{ |
60
|
8 |
|
$this->reference = $reference; |
61
|
8 |
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return int |
65
|
|
|
*/ |
66
|
5 |
|
public function getPositiveVotes(): int |
67
|
|
|
{ |
68
|
5 |
|
return $this->positiveVotes; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param int $positiveVotes |
73
|
|
|
*/ |
74
|
1 |
|
public function setPositiveVotes(int $positiveVotes) |
75
|
|
|
{ |
76
|
1 |
|
$this->positiveVotes = $positiveVotes; |
77
|
1 |
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return int |
81
|
|
|
*/ |
82
|
5 |
|
public function getNegativeVotes(): int |
83
|
|
|
{ |
84
|
5 |
|
return $this->negativeVotes; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param int $negativeVotes |
89
|
|
|
*/ |
90
|
1 |
|
public function setNegativeVotes(int $negativeVotes) |
91
|
|
|
{ |
92
|
1 |
|
$this->negativeVotes = $negativeVotes; |
93
|
1 |
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return int |
97
|
|
|
*/ |
98
|
2 |
|
public function getUserVotes(): int |
99
|
|
|
{ |
100
|
2 |
|
return $this->userVotes; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param int $userVotes |
105
|
|
|
*/ |
106
|
1 |
|
public function setUserVotes(int $userVotes) |
107
|
|
|
{ |
108
|
1 |
|
$this->userVotes = $userVotes; |
109
|
1 |
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return int |
113
|
|
|
*/ |
114
|
2 |
|
public function getAnonymousVotes(): int |
115
|
|
|
{ |
116
|
2 |
|
return $this->anonymousVotes; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param int $anonymousVotes |
121
|
|
|
*/ |
122
|
1 |
|
public function setAnonymousVotes(int $anonymousVotes) |
123
|
|
|
{ |
124
|
1 |
|
$this->anonymousVotes = $anonymousVotes; |
125
|
1 |
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @param boolean $positive |
129
|
|
|
* @param boolean $anonymous |
130
|
|
|
*/ |
131
|
3 |
|
public function addVote(bool $positive, $anonymous = true) |
132
|
|
|
{ |
133
|
3 |
|
if ($positive) { |
134
|
2 |
|
$this->positiveVotes++; |
135
|
2 |
|
if ($anonymous) { |
136
|
1 |
|
$this->anonymousVotes++; |
137
|
|
|
} else { |
138
|
2 |
|
$this->userVotes++; |
139
|
|
|
} |
140
|
|
|
} else { |
141
|
1 |
|
$this->negativeVotes++; |
142
|
|
|
} |
143
|
3 |
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return boolean |
147
|
|
|
*/ |
148
|
1 |
|
public function isPublished(): bool |
149
|
|
|
{ |
150
|
1 |
|
return $this->published; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @param boolean $published |
155
|
|
|
*/ |
156
|
1 |
|
public function setPublished(bool $published) |
157
|
|
|
{ |
158
|
1 |
|
$this->published = $published; |
159
|
|
|
} |
160
|
|
|
} |