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

PostVoteComment::createChrono()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
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_comment")
15
 */
16
class PostVoteComment 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="comments")
29
     * @ORM\JoinColumn(name="post_id", referencedColumnName="id", onDelete="CASCADE")
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(name="created_at", type="datetime")
51
     */
52
    protected $createdAt;
53
54
    /**
55
     * @ORM\Column(name="updated_at", type="datetime")
56
     */
57
    protected $updatedAt;
58
59
    /** @PrePersist */
60
    public function createChrono()
61
    {
62
        $this->createdAt = new \DateTime("now");
63
        $this->updatedAt = new \DateTime("now");
64
    }
65
66
    /** @PreUpdate */
67
    public function updateChrono()
68
    {
69
        $this->updatedAt = new \DateTime("now");
70
    }
71
72
    /**
73
     * @return the unknown_type
74
     */
75
    public function getId()
76
    {
77
        return $this->id;
78
    }
79
80
    /**
81
     * @param unknown_type $id
82
     */
83
    public function setId($id)
84
    {
85
        $this->id = $id;
86
87
        return $this;
88
    }
89
90
    /**
91
     * @return string unknown_type
92
     */
93
    public function getIp()
94
    {
95
        return $this->ip;
96
    }
97
98
    /**
99
     * @param string $ip
100
     */
101
    public function setIp($ip)
102
    {
103
        $this->ip = $ip;
104
105
        return $this;
106
    }
107
108
   /**
109
    * @return the unknown_type
110
    */
111
    public function getUserId()
112
    {
113
        return $this->userId;
114
    }
115
116
    /**
117
     * @param unknown_type $userId
118
     */
119
    public function setUserId($userId)
120
    {
121
        $this->userId = $userId;
122
123
        return $this;
124
    }
125
126
    /**
127
     * @return the unknown_type
128
     */
129
    public function getPost()
130
    {
131
        return $this->post;
132
    }
133
134
    /**
135
     * @param unknown_type $post
136
     */
137
    public function setPost($post)
138
    {
139
        // Check that there is no drawback using the cascading update from PostVoteEntry
140
        $post->addComment($this);
141
        $this->post = $post;
142
143
        return $this;
144
    }
145
146
    /**
147
    * @return the unknown_type
148
    */
149
    public function getMessage()
150
    {
151
        return $this->message;
152
    }
153
154
    /**
155
     * @param unknown_type $message
156
     */
157
    public function setMessage($message)
158
    {
159
        $this->message = $message;
160
161
        return $this;
162
    }
163
164
    /**
165
     * @return the unknown_type
166
     */
167
    public function getCreatedAt()
168
    {
169
        return $this->createdAt;
170
    }
171
172
    /**
173
     * @param unknown_type $createdAt
174
     */
175
    public function setCreatedAt($createdAt)
176
    {
177
        $this->createdAt = $createdAt;
178
179
        return $this;
180
    }
181
182
    /**
183
     * @return the unknown_type
184
     */
185
    public function getUpdatedAt()
186
    {
187
        return $this->updatedAt;
188
    }
189
190
    /**
191
     * @param unknown_type $updatedAt
192
     */
193
    public function setUpdatedAt($updatedAt)
194
    {
195
        $this->updatedAt = $updatedAt;
196
197
        return $this;
198
    }
199
200
    /**
201
     * Convert the object to an array.
202
     *
203
     * @return array
204
     */
205
    public function getArrayCopy()
206
    {
207
        $obj_vars = get_object_vars($this);
208
209
        return $obj_vars;
210
    }
211
212
    /**
213
     * Populate from an array.
214
     *
215
     * @param array $data
216
     */
217
    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...
218
    {
219
    }
220
221
    public function setInputFilter(InputFilterInterface $inputFilter)
222
    {
223
        throw new \Exception("Not used");
224
    }
225
226
    public function getInputFilter()
227
    {
228
        if (!$this->inputFilter) {
229
            $inputFilter = new InputFilter();
230
231
            $this->inputFilter = $inputFilter;
232
        }
233
234
        return $this->inputFilter;
235
    }
236
}
237