GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 851100...f799d7 )
by Borut
15:15
created

UserActionEntity::prePersist()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Application\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * User action Entity.
9
 *
10
 * @ORM\Table(name="user_actions")
11
 * @ORM\Entity(repositoryClass="Application\Repository\UserActionRepository")
12
 * @ORM\HasLifecycleCallbacks()
13
 *
14
 * @author Borut Balažek <[email protected]>
15
 */
16
class UserActionEntity
17
{
18
    /*************** Variables ***************/
19
    /********** General Variables **********/
20
    /**
21
     * @var int
22
     *
23
     * @ORM\Column(name="id", type="integer")
24
     * @ORM\Id
25
     * @ORM\GeneratedValue(strategy="IDENTITY")
26
     */
27
    protected $id;
28
29
    /**
30
     * @var string
31
     *
32
     * @ORM\Column(name="`key`", type="text", nullable=true)
33
     */
34
    protected $key;
35
36
    /**
37
     * @var string
38
     *
39
     * @ORM\Column(name="type", type="string", length=64, nullable=true)
40
     */
41
    protected $type;
42
43
    /**
44
     * @var string
45
     *
46
     * @ORM\Column(name="message", type="text", nullable=true)
47
     */
48
    protected $message;
49
50
    /**
51
     * @var string
52
     *
53
     * @ORM\Column(name="data", type="text", nullable=true)
54
     */
55
    protected $data;
56
57
    /**
58
     * @var string
59
     *
60
     * @ORM\Column(name="ip", type="string", length=255, nullable=true)
61
     */
62
    protected $ip;
63
64
    /**
65
     * @var string
66
     *
67
     * @ORM\Column(name="user_agent", type="text", nullable=true)
68
     */
69
    protected $userAgent;
70
71
    /**
72
     * @var \DateTime
73
     *
74
     * @ORM\Column(name="time_created", type="datetime")
75
     */
76
    protected $timeCreated;
77
78
    /**
79
     * @var \DateTime
80
     *
81
     * @ORM\Column(name="time_updated", type="datetime")
82
     */
83
    protected $timeUpdated;
84
85
    /***** Relationship Variables *****/
86
    /**
87
     * @ORM\ManyToOne(targetEntity="Application\Entity\UserEntity", inversedBy="userActions")
88
     */
89
    protected $user;
90
91
    /*************** Methods ***************/
92
    /*** Id ***/
93
    /**
94
     * @return int
95
     */
96
    public function getId()
97
    {
98
        return $this->id;
99
    }
100
101
    /**
102
     * @param $id
103
     *
104
     * @return UserActionEntity
105
     */
106
    public function setId($id)
107
    {
108
        $this->id = $id;
109
110
        return $this;
111
    }
112
113
    /*** Key ***/
114
    /**
115
     * @return string
116
     */
117
    public function getKey()
118
    {
119
        return $this->key;
120
    }
121
122
    /**
123
     * @param $key
124
     *
125
     * @return UserActionEntity
126
     */
127
    public function setKey($key)
128
    {
129
        $this->key = $key;
130
131
        return $this;
132
    }
133
134
    /*** Type ***/
135
    /**
136
     * @return string
137
     */
138
    public function getType()
139
    {
140
        return $this->type;
141
    }
142
143
    /**
144
     * @param $type
145
     *
146
     * @return UserActionEntity
147
     */
148
    public function setType($type)
149
    {
150
        $this->type = $type;
151
152
        return $this;
153
    }
154
155
    /*** Message ***/
156
    /**
157
     * @return string
158
     */
159
    public function getMessage()
160
    {
161
        return $this->message;
162
    }
163
164
    /**
165
     * @param $message
166
     *
167
     * @return UserActionEntity
168
     */
169
    public function setMessage($message)
170
    {
171
        $this->message = $message;
172
173
        return $this;
174
    }
175
176
    /*** Data ***/
177
    /**
178
     * @return string
179
     */
180
    public function getData()
181
    {
182
        return $this->data;
183
    }
184
185
    /**
186
     * @param $data
187
     *
188
     * @return UserActionEntity
189
     */
190
    public function setData($data)
191
    {
192
        if (is_array($data)) {
193
            $data = json_encode($data);
194
195
            $data = str_replace("\u0000*", '', $data);
196
            $data = str_replace("\u0000", '', $data);
197
        }
198
199
        $this->data = $data;
200
201
        return $this;
202
    }
203
204
    /*** IP ***/
205
    /**
206
     * @return string
207
     */
208
    public function getIp()
209
    {
210
        return $this->ip;
211
    }
212
213
    /**
214
     * @param $ip
215
     *
216
     * @return UserActionEntity
217
     */
218
    public function setIp($ip)
219
    {
220
        $this->ip = $ip;
221
222
        return $this;
223
    }
224
225
    /*** User agent ***/
226
    /**
227
     * @return string
228
     */
229
    public function getUserAgent()
230
    {
231
        return $this->userAgent;
232
    }
233
234
    /**
235
     * @param $userAgent
236
     *
237
     * @return UserActionEntity
238
     */
239
    public function setUserAgent($userAgent)
240
    {
241
        $this->userAgent = $userAgent;
242
243
        return $this;
244
    }
245
246
    /*** Time created ***/
247
    /**
248
     * @return \DateTime
249
     */
250
    public function getTimeCreated()
251
    {
252
        return $this->timeCreated;
253
    }
254
255
    /**
256
     * @param \DateTime $timeCreated
257
     *
258
     * @return UserActionEntity
259
     */
260
    public function setTimeCreated(\DateTime $timeCreated)
261
    {
262
        $this->timeCreated = $timeCreated;
263
264
        return $this;
265
    }
266
267
    /*** Time updated ***/
268
    /**
269
     * @return \DateTime
270
     */
271
    public function getTimeUpdated()
272
    {
273
        return $this->timeUpdated;
274
    }
275
276
    /**
277
     * @param \DateTime $timeUpdated
278
     *
279
     * @return UserActionEntity
280
     */
281
    public function setTimeUpdated(\DateTime $timeUpdated)
282
    {
283
        $this->timeUpdated = $timeUpdated;
284
285
        return $this;
286
    }
287
288
    /*** User ***/
289
    /**
290
     * @return UserEntity $user
291
     */
292
    public function getUser()
293
    {
294
        return $this->user;
295
    }
296
297
    /**
298
     * @param UserEntity $user
299
     *
300
     * @return UserActionEntity
301
     */
302
    public function setUser(\Application\Entity\UserEntity $user = null)
303
    {
304
        $this->user = $user;
305
306
        return $this;
307
    }
308
309
    /********** Other Methods **********/
310
    /**
311
     * @return array
312
     */
313
    public function toArray()
314
    {
315
        return array(
316
            'id' => $this->getId(),
317
            'key' => $this->getKey(),
318
            'ip' => $this->getIp(),
319
            'time_created' => $this->getTimeCreated()->format(DATE_ATOM),
320
        );
321
    }
322
323
    /********** Callback Methods **********/
324
    /**
325
     * @ORM\PreUpdate
326
     */
327
    public function preUpdate()
328
    {
329
        $this->setTimeUpdated(new \DateTime('now'));
330
    }
331
332
    /**
333
     * @ORM\PrePersist
334
     */
335
    public function prePersist()
336
    {
337
        $this->setTimeUpdated(new \DateTime('now'));
338
        $this->setTimeCreated(new \DateTime('now'));
339
    }
340
}
341