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 ( ad0cea...d7a0cd )
by Borut
02:49
created

ProfileEntity::setUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Application\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * Profile Entity
9
 *
10
 * @ORM\Table(name="profiles")
11
 * @ORM\Entity(repositoryClass="Application\Repository\ProfileRepository")
12
 * @ORM\HasLifecycleCallbacks()
13
 *
14
 * @author Borut Balažek <[email protected]>
15
 */
16
class ProfileEntity
17
    extends AbstractImageUpload
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
18
{
19
    /**
20
     * @var integer
21
     *
22
     * @ORM\Column(name="id", type="integer")
23
     * @ORM\Id
24
     * @ORM\GeneratedValue(strategy="IDENTITY")
25
     */
26
    protected $id;
27
28
    /**
29
     * Mr., Mrs., Ms., Ing., ...
30
     *
31
     * @var string
32
     *
33
     * @ORM\Column(name="title", type="string", length=8, nullable=true)
34
     */
35
    protected $title;
36
37
    /**
38
     * @var string
39
     *
40
     * @ORM\Column(name="first_name", type="string", length=32, nullable=true)
41
     */
42
    protected $firstName;
43
44
    /**
45
     * @var string
46
     *
47
     * @ORM\Column(name="middle_name", type="string", length=32, nullable=true)
48
     */
49
    protected $middleName;
50
51
    /**
52
     * @var string
53
     *
54
     * @ORM\Column(name="last_name", type="string", length=32, nullable=true)
55
     */
56
    protected $lastName;
57
58
    /**
59
     * male or female?
60
     *
61
     * @var string
62
     *
63
     * @ORM\Column(name="gender", type="string", length=8, nullable=true)
64
     */
65
    protected $gender;
66
67
    /**
68
     * @var \DateTime
69
     *
70
     * @ORM\Column(name="birthdate", type="datetime", nullable=true)
71
     */
72
    protected $birthdate;
73
74
    /**
75
     * @var string
76
     *
77
     * @ORM\Column(name="image_url", type="text", nullable=true)
78
     */
79
    protected $imageUrl;
80
81
    /**
82
     * @ORM\OneToOne(targetEntity="Application\Entity\UserEntity", inversedBy="profile")
83
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
84
     */
85
    protected $user;
86
87
    /*** Id ***/
88
    /**
89
     * @return integer
90
     */
91
    public function getId()
92
    {
93
        return $this->id;
94
    }
95
96
    /**
97
     * @param $id
98
     *
99
     * @return ProfileEntity
100
     */
101
    public function setId($id)
102
    {
103
        $this->id = $id;
104
105
        return $this;
106
    }
107
108
    /*** Title ***/
109
    /**
110
     * @return string
111
     */
112
    public function getTitle()
113
    {
114
        return $this->title;
115
    }
116
117
    /**
118
     * @param $title
119
     *
120
     * @return ProfileEntity
121
     */
122
    public function setTitle($title)
123
    {
124
        $this->title = $title;
125
126
        return $this;
127
    }
128
129
    /*** Name ***/
130
    /**
131
     * @return string
132
     */
133
    public function getName()
134
    {
135
        return $this->getFirstName().' '.$this->getLastName();
136
    }
137
138
    /*** First name ***/
139
    /**
140
     * @return string
141
     */
142
    public function getFirstName()
143
    {
144
        return $this->firstName;
145
    }
146
147
    /**
148
     * @param $firstName
149
     *
150
     * @return ProfileEntity
151
     */
152
    public function setFirstName($firstName)
153
    {
154
        $this->firstName = $firstName;
155
156
        return $this;
157
    }
158
159
    /*** Middle name ***/
160
    /**
161
     * @return string
162
     */
163
    public function getMiddleName()
164
    {
165
        return $this->middleName;
166
    }
167
168
    /**
169
     * @param $middleName
170
     *
171
     * @return ProfileEntity
172
     */
173
    public function setMiddleName($middleName)
174
    {
175
        $this->middleName = $middleName;
176
177
        return $this;
178
    }
179
180
    /*** Last name ***/
181
    /**
182
     * @return string
183
     */
184
    public function getLastName()
185
    {
186
        return $this->lastName;
187
    }
188
189
    /**
190
     * @param $lastName
191
     *
192
     * @return ProfileEntity
193
     */
194
    public function setLastName($lastName)
195
    {
196
        $this->lastName = $lastName;
197
198
        return $this;
199
    }
200
201
    /*** Full name ***/
202
    /**
203
     * @return string
204
     */
205
    public function getFullName()
206
    {
207
        return trim(
208
            $this->getTitle().' '.
209
            $this->getFirstName().' '.
210
            $this->getMiddleName().' '.
211
            $this->getLastName()
212
        );
213
    }
214
215
    /*** Gender ***/
216
    /**
217
     * @return string
218
     */
219
    public function getGender()
220
    {
221
        return $this->gender;
222
    }
223
224
    /**
225
     * @param $gender
226
     *
227
     * @return ProfileEntity
228
     */
229
    public function setGender($gender)
230
    {
231
        $this->gender = $gender;
232
233
        return $this;
234
    }
235
236
    /*** Birthdate ***/
237
    /**
238
     * @return string
239
     */
240
    public function getBirthdate()
241
    {
242
        return $this->birthdate;
243
    }
244
245
    /**
246
     * @param mixed $birthdate
247
     *
248
     * @return ProfileEntity
249
     */
250
    public function setBirthdate($birthdate = null)
251
    {
252
        if ($birthdate === null) {
253
            $this->birthdate = null;
254
        } elseif ($birthdate instanceof \DateTime) {
255
            $this->birthdate = $birthdate;
256
        } else {
257
            $this->birthdate = new \DateTime($birthdate);
258
        }
259
260
        return $this;
261
    }
262
263
    /*** Age ***/
264
    /**
265
     * @return string
266
     */
267
    public function getAge($format = '%y')
268
    {
269
        return $this->getBirthdate()
270
            ? $this->getBirthdate()->diff(new \DateTime())->format($format)
271
            : null
272
        ;
273
    }
274
275
    /*** User ***/
276
    /**
277
     * @return UserEntity
278
     */
279
    public function getUser()
280
    {
281
        return $this->user;
282
    }
283
284
    /**
285
     * @param UserEntity $user
286
     *
287
     * @return ProfileEntity
288
     */
289
    public function setUser(UserEntity $user)
290
    {
291
        $this->user = $user;
292
293
        return $this;
294
    }
295
296
    /**
297
     * @return array
298
     */
299
    public function toArray()
300
    {
301
        return array(
302
            'id' => $this->getId(),
303
            'title' => $this->getTitle(),
304
            'full_name' => $this->getFullName(),
305
            'first_name' => $this->getFirstName(),
306
            'middle_name' => $this->getMiddleName(),
307
            'last_name' => $this->getLastName(),
308
            'gender' => $this->getGender(),
309
            'birthdate' => $this->getBirthdate()
310
                ? $this->getBirthdate()->format(DATE_ATOM)
311
                : null,
312
            'image_url' => $this->getImageUrl(),
313
        );
314
    }
315
}
316