Completed
Pull Request — master (#144)
by Serhii
24:57
created

User::getOrders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Doctrine\Common\Collections\ArrayCollection;
7
use Symfony\Component\Security\Core\User\UserInterface;
8
use JMS\Serializer\Annotation\ExclusionPolicy;
9
use JMS\Serializer\Annotation\Expose;
10
use JMS\Serializer\Tests\Fixtures\Order;
11
use Symfony\Component\Validator\Constraints as Assert;
12
use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
13
use AppBundle\Traits\TimestampableTrait;
14
use Gedmo\Blameable\Traits\BlameableEntity;
15
use Gedmo\Mapping\Annotation as Gedmo;
16
use AppBundle\Traits\DeletedByTrait;
17
18
/**
19
 * @ORM\Table(name="users")
20
 * @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
21
 *
22
 * @DoctrineAssert\UniqueEntity(
23
 *     fields="facebookId",
24
 *     message="facebookId already exists",
25
 *     groups={"uniqFacebookId"}
26
 * )
27
 * @DoctrineAssert\UniqueEntity(
28
 *     fields="apiKey",
29
 *     message="apikey already exists",
30
 *     groups={"uniqApikey"}
31
 * )
32
 *
33
 * @ExclusionPolicy("all")
34
 * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
35
 */
36
class User implements UserInterface
37
{
38
    use TimestampableTrait, BlameableEntity, DeletedByTrait;
39
    /**
40
     * @var int
41
     *
42
     * @ORM\Column(name="id", type="integer")
43
     * @ORM\Id
44
     * @ORM\GeneratedValue(strategy="AUTO")
45
     */
46
    protected $id;
47
48
    /**
49
     * @var string
50
     *
51
     * @ORM\Column(name="first_name", type="string", length=100, nullable=true)
52
     *
53
     * @Assert\Regex(pattern="/\d/", match=false)
54
     * @Assert\Type("string")
55
     * @Assert\Length(min=2, max=100)
56
     * @Assert\NotBlank(
57
     *     message="not.blank"
58
     * )
59
     *
60
     * @Expose
61
     */
62
    protected $firstName;
63
64
    /**
65
     * @var string
66
     *
67
     * @ORM\Column(name="last_name", type="string", length=100, nullable=true)
68
     *
69
     * @Assert\Regex(pattern="/\d/", match=false)
70
     * @Assert\Type("string")
71
     * @Assert\Length(min=2, max=100)
72
     * @Assert\NotBlank(
73
     *     message="not.blank"
74
     * )
75
     *
76
     * @Expose
77
     */
78
    protected $lastName;
79
80
    /**
81
     * @var string
82
     *
83
     * @ORM\Column(name="email", type="string", length=100, nullable=true)
84
     *
85
     * @Assert\Email()
86
     * @Assert\Type("string")
87
     * @Assert\Length(max=100)
88
     * @Assert\NotBlank(
89
     *     message="not.blank"
90
     * )
91
     *
92
     * @Expose
93
     */
94
    protected $email;
95
96
    /**
97
     * @var string
98
     *
99
     * @ORM\Column(name="username", type="string", length=100)
100
     *
101
     * @Assert\Type("string")
102
     * @Assert\Length(max=100)
103
     */
104
    protected $username;
105
106
    /**
107
     * @var string
108
     *
109
     * @ORM\Column(name="api_key", type="string", length=255, nullable=true, unique=true)
110
     *
111
     * @Assert\Type("string")
112
     * @Assert\Length(max=255)
113
     */
114
    private $apiKey;
115
116
    /**
117
     * @var string
118
     *
119
     * @ORM\Column(name="facebook_id", type="string", length=255, nullable=true, unique=true)
120
     *
121
     * @Assert\Type("string")
122
     * @Assert\Length(max=255)
123
     */
124
    private $facebookId;
125
126
    /**
127
     * @var ArrayCollection|Order[]
128
     *
129
     * @ORM\OneToMany(
130
     *     targetEntity="AppBundle\Entity\UserOrder",
131
     *     mappedBy="user",
132
     *     cascade={"persist", "remove"},
133
     *     orphanRemoval=true
134
     * )
135
     */
136
    private $orders;
137
138
    /**
139
     * @var string
140
     *
141
     * @ORM\Column(name="role", type="string", length=50)
142
     */
143
    private $role;
144
145
    /**
146
     * Constructor
147
     */
148 42
    public function __construct()
149
    {
150 42
        $this->orders = new ArrayCollection();
151 42
    }
152
    /**
153
     * @return int
154
     */
155 3
    public function getId()
156
    {
157 3
        return $this->id;
158
    }
159
160
    /**
161
     * @param string $apiKey
162
     *
163
     * @return User
164
     */
165 42
    public function setApiKey($apiKey)
166
    {
167 42
        $this->apiKey = $apiKey;
168
169 42
        return $this;
170
    }
171
172
    /**
173
     * @return string
174
     */
175 8
    public function getApiKey()
176
    {
177 8
        return $this->apiKey;
178
    }
179
180
    /**
181
     * Add order.
182
     *
183
     * @param UserOrder $order
184
     *
185
     * @return self
186
     */
187 4
    public function addOrder(UserOrder $order)
188
    {
189 4
        $this->orders[] = $order;
190
191 4
        return $this;
192
    }
193
194
    /**
195
     * Remove order.
196
     *
197
     * @param UserOrder $order
198
     * @return User
199
     */
200
    public function removeOrder(UserOrder $order)
201
    {
202
        $this->orders->removeElement($order);
203
        return $this;
204
    }
205
206
    /**
207
     * Get orders.
208
     *
209
     * @return \Doctrine\Common\Collections\Collection
210
     */
211 4
    public function getOrders()
212
    {
213 4
        return $this->orders;
214
    }
215
216
    /**
217
     * @param Order[]|ArrayCollection $oreder
0 ignored issues
show
Documentation introduced by
There is no parameter named $oreder. Did you maybe mean $order?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
218
     */
219
    public function setPriceCategories($order)
220
    {
221
        $this->orders[] = $order;
222
    }
223
224
    /**
225
     * @param string $role
226
     *
227
     * @return User
228
     */
229 42
    public function setRole($role)
230
    {
231 42
        $this->role = $role;
232
233 42
        return $this;
234
    }
235
236
    /**
237
     * @return string
238
     */
239
    public function getRole()
240
    {
241
        return $this->role;
242
    }
243
244
245
246
    /**
247
     * @inheritdoc
248
     */
249 13
    public function getRoles()
250
    {
251 13
        return array($this->role);
252
    }
253
254
    /**
255
     * @inheritdoc
256
     */
257
    public function getPassword()
258
    {
259
    }
260
261
    /**
262
     * @inheritdoc
263
     */
264
    public function getSalt()
265
    {
266
    }
267
268
    /**
269
     * @inheritdoc
270
     */
271 13
    public function eraseCredentials()
272
    {
273 13
    }
274
275
    /**
276
     * @param string $facebookId
277
     *
278
     * @return User
279
     */
280 15
    public function setFacebookId($facebookId)
281
    {
282 15
        $this->facebookId = $facebookId;
283
284 15
        return $this;
285
    }
286
287
    /**
288
     * @return string
289
     */
290
    public function getFacebookId()
291
    {
292
        return $this->facebookId;
293
    }
294
295
    /**
296
     * @param string $username
297
     *
298
     * @return User
299
     */
300 42
    public function setUsername($username)
301
    {
302 42
        $this->username = $username;
303
304 42
        return $this;
305
    }
306
307
    /**
308
     * @return string
309
     */
310 13
    public function getUsername()
311
    {
312 13
        return $this->username;
313
    }
314
315
    /**
316
     * @param string $firstName
317
     *
318
     * @return User
319
     */
320 8
    public function setFirstName($firstName)
321
    {
322 8
        $this->firstName = $firstName;
323
324 8
        return $this;
325
    }
326
327
    /**
328
     * @return string
329
     */
330 4
    public function getFirstName()
331
    {
332 4
        return $this->firstName;
333
    }
334
335
    /**
336
     * @param string $lastName
337
     *
338
     * @return User
339
     */
340 8
    public function setLastName($lastName)
341
    {
342 8
        $this->lastName = $lastName;
343
344 8
        return $this;
345
    }
346
347
    /**
348
     * @return string
349
     */
350 4
    public function getLastName()
351
    {
352 4
        return $this->lastName;
353
    }
354
355
    /**
356
     * @param string $email
357
     *
358
     * @return User
359
     */
360 8
    public function setEmail($email)
361
    {
362 8
        $this->email = $email;
363
364 8
        return $this;
365
    }
366
367
    /**
368
     * @return string
369
     */
370 4
    public function getEmail()
371
    {
372 4
        return $this->email;
373
    }
374
375 2
    public function __toString()
376
    {
377 2
        return (string) $this->getId();
378
    }
379
}
380