Completed
Push — develop ( b3b9d6...b879cb )
by greg
19:23 queued 20s
created

PostVoteVote::updateChrono()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace PlaygroundGame\Entity;
3
4
use Doctrine\ORM\Mapping as ORM;
5
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
6
use Doctrine\ORM\Mapping\PrePersist;
7
use Doctrine\ORM\Mapping\PreUpdate;
8
use Zend\InputFilter\InputFilter;
9
use Zend\InputFilter\InputFilterAwareInterface;
10
use Zend\InputFilter\InputFilterInterface;
11
12
/**
13
 * @ORM\Entity @HasLifecycleCallbacks
14
 * @ORM\Table(name="game_postvote_vote")
15
 */
16
class PostVoteVote implements InputFilterAwareInterface
17
{
18
    protected $inputFilter;
19
20
    /**
21
     * @ORM\Id
22
     * @ORM\Column(type="integer");
23
     * @ORM\GeneratedValue(strategy="AUTO")
24
     */
25
    protected $id;
26
27
    /**
28
     * @ORM\ManyToOne(targetEntity="PostVotePost", inversedBy="votes")
29
     *
30
     **/
31
    protected $post;
32
33
    /**
34
     * The link to the user is not explicit as it's possible to vote anonymously....
35
     * @ORM\Column(type="integer", nullable=true)
36
     */
37
    protected $userId;
38
39
    /**
40
     * @ORM\Column(type="text", nullable=true)
41
     */
42
    protected $ip;
43
44
    /**
45
     * @ORM\Column(type="text", nullable=true)
46
     */
47
    protected $message;
48
49
    /**
50
     * @ORM\Column(type="string", nullable=true)
51
     */
52
    protected $note;
53
54
    /**
55
     * @ORM\Column(name="created_at", type="datetime")
56
     */
57
    protected $createdAt;
58
59
    /**
60
     * @ORM\Column(name="updated_at", type="datetime")
61
     */
62
    protected $updatedAt;
63
64
    /** @PrePersist */
65
    public function createChrono()
66
    {
67
        $this->createdAt = new \DateTime("now");
68
        $this->updatedAt = new \DateTime("now");
69
    }
70
71
    /** @PreUpdate */
72
    public function updateChrono()
73
    {
74
        $this->updatedAt = new \DateTime("now");
75
    }
76
77
    /**
78
     * @return the unknown_type
79
     */
80
    public function getId()
81
    {
82
        return $this->id;
83
    }
84
85
    /**
86
     * @param unknown_type $id
87
     */
88
    public function setId($id)
89
    {
90
        $this->id = $id;
91
92
        return $this;
93
    }
94
95
    /**
96
     * @return string unknown_type
97
     */
98
    public function getIp()
99
    {
100
        return $this->ip;
101
    }
102
103
    /**
104
     * @param string $ip
105
     */
106
    public function setIp($ip)
107
    {
108
        $this->ip = $ip;
109
110
        return $this;
111
    }
112
113
   /**
114
    * @return the unknown_type
115
    */
116
    public function getUserId()
117
    {
118
        return $this->userId;
119
    }
120
121
    /**
122
     * @param unknown_type $userId
123
     */
124
    public function setUserId($userId)
125
    {
126
        $this->userId = $userId;
127
128
        return $this;
129
    }
130
131
    /**
132
     * @return the unknown_type
133
     */
134
    public function getPost()
135
    {
136
        return $this->post;
137
    }
138
139
    /**
140
     * @param unknown_type $post
141
     */
142
    public function setPost($post)
143
    {
144
        // Check that there is no drawback using the cascading update from PostVoteEntry
145
        $post->addVote($this);
146
        $this->post = $post;
147
148
        return $this;
149
    }
150
151
    /**
152
    * @return the unknown_type
153
    */
154
    public function getMessage()
155
    {
156
        return $this->message;
157
    }
158
159
    /**
160
     * @param unknown_type $message
161
     */
162
    public function setMessage($message)
163
    {
164
        $this->message = $message;
165
166
        return $this;
167
    }
168
169
    /**
170
    * @return the unknown_type
171
    */
172
    public function getNote()
173
    {
174
        return $this->note;
175
    }
176
177
    /**
178
     * @param unknown_type $note
179
     */
180
    public function setNote($note)
181
    {
182
        $this->note = $note;
183
184
        return $this;
185
    }
186
187
    /**
188
     * @return the unknown_type
189
     */
190
    public function getCreatedAt()
191
    {
192
        return $this->createdAt;
193
    }
194
195
    /**
196
     * @param unknown_type $createdAt
197
     */
198
    public function setCreatedAt($createdAt)
199
    {
200
        $this->createdAt = $createdAt;
201
202
        return $this;
203
    }
204
205
    /**
206
     * @return the unknown_type
207
     */
208
    public function getUpdatedAt()
209
    {
210
        return $this->updatedAt;
211
    }
212
213
    /**
214
     * @param unknown_type $updatedAt
215
     */
216
    public function setUpdatedAt($updatedAt)
217
    {
218
        $this->updatedAt = $updatedAt;
219
220
        return $this;
221
    }
222
223
    /**
224
     * Convert the object to an array.
225
     *
226
     * @return array
227
     */
228
    public function getArrayCopy()
229
    {
230
        $obj_vars = get_object_vars($this);
231
232
        return $obj_vars;
233
    }
234
235
    /**
236
     * Populate from an array.
237
     *
238
     * @param array $data
239
     */
240
    public function populate($data = array())
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
241
    {
242
    }
243
244
    public function setInputFilter(InputFilterInterface $inputFilter)
245
    {
246
        throw new \Exception("Not used");
247
    }
248
249
    public function getInputFilter()
250
    {
251
        if (!$this->inputFilter) {
252
            $inputFilter = new InputFilter();
253
254
            $this->inputFilter = $inputFilter;
255
        }
256
257
        return $this->inputFilter;
258
    }
259
}
260