Completed
Push — master ( 972dec...29f109 )
by greg
31:27 queued 13:20
created

PostVotePostElement   A

Complexity

Total Complexity 25

Size/Duplication

Total Lines 251
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 25
c 2
b 0
f 0
lcom 2
cbo 1
dl 0
loc 251
rs 10

23 Methods

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