Completed
Push — master ( e95261...40aeb3 )
by greg
04:30 queued 01:59
created

PostVoteShare   A

Complexity

Total Complexity 25

Size/Duplication

Total Lines 259
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 2

Importance

Changes 0
Metric Value
wmc 25
lcom 3
cbo 2
dl 0
loc 259
rs 10
c 0
b 0
f 0

24 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createChrono() 0 5 1
A updateChrono() 0 4 1
A getId() 0 4 1
A setId() 0 6 1
A getIp() 0 4 1
A setIp() 0 6 1
A getUser() 0 4 1
A setUser() 0 6 1
A getPost() 0 4 1
A setPost() 0 8 1
A getPostvote() 0 4 1
A setPostvote() 0 6 1
A getOrigin() 0 4 1
A setOrigin() 0 6 1
A getCreatedAt() 0 4 1
A setCreatedAt() 0 6 1
A getUpdatedAt() 0 4 1
A setUpdatedAt() 0 6 1
A getArrayCopy() 0 6 1
A jsonSerialize() 0 4 1
A populate() 0 3 1
A setInputFilter() 0 4 1
A getInputFilter() 0 10 2
1
<?php
2
namespace PlaygroundGame\Entity;
3
4
use Doctrine\Common\Collections\ArrayCollection;
5
use Doctrine\ORM\Mapping as ORM;
6
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
7
use Doctrine\ORM\Mapping\PrePersist;
8
use Doctrine\ORM\Mapping\PreUpdate;
9
use Zend\InputFilter\InputFilter;
10
use Zend\InputFilter\InputFilterAwareInterface;
11
use Zend\InputFilter\InputFilterInterface;
12
13
/**
14
 * @ORM\Entity @HasLifecycleCallbacks
15
 * @ORM\Table(name="game_postvote_share")
16
 */
17
class PostVoteShare implements InputFilterAwareInterface, \JsonSerializable
18
{
19
    protected $inputFilter;
20
21
    /**
22
     * @ORM\Id
23
     * @ORM\Column(type="integer");
24
     * @ORM\GeneratedValue(strategy="AUTO")
25
     */
26
    protected $id;
27
28
    /**
29
     * @ORM\ManyToOne(targetEntity="PostVotePost", inversedBy="shares")
30
     * @ORM\JoinColumn(name="post_id", referencedColumnName="id", onDelete="CASCADE")
31
     **/
32
    protected $post;
33
34
    /**
35
     * @ORM\ManyToOne(targetEntity="PostVote")
36
     **/
37
    protected $postvote;
38
39
    /**
40
     * @ORM\ManyToOne(targetEntity="PlaygroundUser\Entity\User")
41
     * @ORM\JoinColumn(name="user_id", referencedColumnName="user_id", onDelete="CASCADE")
42
     **/
43
    protected $user;
44
45
    /**
46
     * @ORM\Column(type="text", nullable=true)
47
     */
48
    protected $ip;
49
50
    /**
51
     * @ORM\Column(type="text", nullable=true)
52
     */
53
    protected $origin;
54
55
    /**
56
     * @ORM\Column(name="created_at", type="datetime")
57
     */
58
    protected $createdAt;
59
60
    /**
61
     * @ORM\Column(name="updated_at", type="datetime")
62
     */
63
    protected $updatedAt;
64
65
    public function __construct()
66
    {
67
        $this->votes = new ArrayCollection();
68
    }
69
70
    /** @PrePersist */
71
    public function createChrono()
72
    {
73
        $this->createdAt = new \DateTime("now");
74
        $this->updatedAt = new \DateTime("now");
75
    }
76
77
    /** @PreUpdate */
78
    public function updateChrono()
79
    {
80
        $this->updatedAt = new \DateTime("now");
81
    }
82
83
    /**
84
     * @return the unknown_type
85
     */
86
    public function getId()
87
    {
88
        return $this->id;
89
    }
90
91
    /**
92
     * @param unknown_type $id
93
     */
94
    public function setId($id)
95
    {
96
        $this->id = $id;
97
98
        return $this;
99
    }
100
101
    /**
102
     * @return string unknown_type
103
     */
104
    public function getIp()
105
    {
106
        return $this->ip;
107
    }
108
109
    /**
110
     * @param string $ip
111
     */
112
    public function setIp($ip)
113
    {
114
        $this->ip = $ip;
115
116
        return $this;
117
    }
118
119
    /**
120
     * @return the unknown_type
121
     */
122
    public function getUser()
123
    {
124
        return $this->user;
125
    }
126
127
    /**
128
     * @param unknown_type $user
129
     */
130
    public function setUser($user)
131
    {
132
        $this->user = $user;
133
134
        return $this;
135
    }
136
137
    /**
138
     * @return the unknown_type
139
     */
140
    public function getPost()
141
    {
142
        return $this->post;
143
    }
144
145
    /**
146
     * @param unknown_type $post
147
     */
148
    public function setPost($post)
149
    {
150
        // Check that there is no drawback using the cascading update from PostVoteShare
151
        $post->addShare($this);
152
        $this->post = $post;
153
154
        return $this;
155
    }
156
157
    /**
158
     * @return the unknown_type
159
     */
160
    public function getPostvote()
161
    {
162
        return $this->postvote;
163
    }
164
165
    /**
166
     * @param unknown_type $postvote
167
     */
168
    public function setPostvote($postvote)
169
    {
170
        $this->postvote = $postvote;
171
172
        return $this;
173
    }
174
175
    /**
176
    * @return the $origin
177
    */
178
    public function getOrigin()
179
    {
180
        return $this->origin;
181
    }
182
183
    /**
184
     * @param string $origin
185
     */
186
    public function setOrigin($origin)
187
    {
188
        $this->origin = $origin;
189
190
        return $this;
191
    }
192
193
    /**
194
     * @return the unknown_type
195
     */
196
    public function getCreatedAt()
197
    {
198
        return $this->createdAt;
199
    }
200
201
    /**
202
     * @param unknown_type $createdAt
203
     */
204
    public function setCreatedAt($createdAt)
205
    {
206
        $this->createdAt = $createdAt;
207
208
        return $this;
209
    }
210
211
    /**
212
     * @return the unknown_type
213
     */
214
    public function getUpdatedAt()
215
    {
216
        return $this->updatedAt;
217
    }
218
219
    /**
220
     * @param unknown_type $updatedAt
221
     */
222
    public function setUpdatedAt($updatedAt)
223
    {
224
        $this->updatedAt = $updatedAt;
225
226
        return $this;
227
    }
228
229
    /**
230
     * Convert the object to an array.
231
     *
232
     * @return array
233
     */
234
    public function getArrayCopy()
235
    {
236
        $obj_vars = get_object_vars($this);
237
238
        return $obj_vars;
239
    }
240
    
241
    /**
242
     * Convert the object to json.
243
     *
244
     * @return array
245
     */
246
    public function jsonSerialize()
247
    {
248
        return $this->getArrayCopy();
249
    }
250
251
    /**
252
     * Populate from an array.
253
     *
254
     * @param array $data
255
     */
256
    public function populate($data = array())
257
    {
258
    }
259
260
    public function setInputFilter(InputFilterInterface $inputFilter)
261
    {
262
        throw new \Exception("Not used");
263
    }
264
265
    public function getInputFilter()
266
    {
267
        if (!$this->inputFilter) {
268
            $inputFilter = new InputFilter();
269
270
            $this->inputFilter = $inputFilter;
271
        }
272
273
        return $this->inputFilter;
274
    }
275
}
276