Passed
Push — master ( e3b080...c6206b )
by Aimeos
17:44
created

FosUser::getSalt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2015
6
 */
7
8
9
namespace Aimeos\ShopBundle\Entity;
10
11
use Doctrine\ORM\Mapping as ORM;
12
use FOS\UserBundle\Model\User as BaseUser;
13
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
14
15
16
/**
17
 * Aimeos\ShopBundle\Entity\FosUser
18
 *
19
 * @ORM\Entity
20
 * @ORM\Table(name: "fos_user",uniqueConstraints={@ORM\UniqueConstraint(name: "unq_fosus_username",columns={"username_canonical"}),@ORM\UniqueConstraint(name: "unq_fosus_confirmtoken",columns={"confirmation_token"}),@ORM\UniqueConstraint(name: "unq_fosus_email",columns={"email_canonical"})},indexes={@ORM\Index(name: "idx_fosus_langid", columns={"langid"}),@ORM\Index(name: "idx_fosus_last_first", columns={"lastname", "firstname"}),@ORM\Index(name: "idx_fosus_post_addr1", columns={"postal", "address1"}),@ORM\Index(name: "idx_fosus_post_city", columns={"postal", "city"}),@ORM\Index(name: "idx_fosus_lastname", columns={"lastname"}),@ORM\Index(name: "idx_fosus_address1", columns={"address1"}),@ORM\Index(name: "idx_fosus_city", columns={"city"})})
21
 */
22
class FosUser extends BaseUser implements PasswordAuthenticatedUserInterface
23
{
24
	/**
25
	 * @ORM\Id
26
	 * @ORM\Column(type: "integer")
27
	 * @ORM\GeneratedValue(strategy: "AUTO")
28
	 */
29
	protected $id;
30
31
	/**
32
	 * @ORM\Column(name: "siteid", type: "string", length=255)
33
	 */
34
	protected $siteid;
35
36
	/**
37
	 * @ORM\Column(name: "salutation", type: "string", length=8)
38
	 */
39
	protected $salutation = '';
40
41
	/**
42
	 * @ORM\Column(name: "company", type: "string", length=100)
43
	 */
44
	protected $company = '';
45
46
	/**
47
	 * @ORM\Column(name: "vatid", type: "string", length=32)
48
	 */
49
	protected $vatid = '';
50
51
	/**
52
	 * @ORM\Column(name: "title", type: "string", length=64)
53
	 */
54
	protected $title = '';
55
56
	/**
57
	 * @ORM\Column(name: "firstname", type: "string", length=64)
58
	 */
59
	protected $firstname = '';
60
61
	/**
62
	 * @ORM\Column(name: "lastname", type: "string", length=64)
63
	 */
64
	protected $lastname = '';
65
66
	/**
67
	 * @ORM\Column(name: "address1", type: "string", length=200)
68
	 */
69
	protected $address1 = '';
70
71
	/**
72
	 * @ORM\Column(name: "address2", type: "string", length=200)
73
	 */
74
	protected $address2 = '';
75
76
	/**
77
	 * @ORM\Column(name: "address3", type: "string", length=200)
78
	 */
79
	protected $address3 = '';
80
81
	/**
82
	 * @ORM\Column(name: "postal", type: "string", length=16)
83
	 */
84
	protected $postal = '';
85
86
	/**
87
	 * @ORM\Column(name: "city", type: "string", length=200)
88
	 */
89
	protected $city = '';
90
91
	/**
92
	 * @ORM\Column(name: "state", type: "string", length=200)
93
	 */
94
	protected $state = '';
95
96
	/**
97
	 * @ORM\Column(name: "langid", type: "string", length=5, nullable=true)
98
	 */
99
	protected $langid = '';
100
101
	/**
102
	 * @ORM\Column(name: "countryid", type: "string", length=2, nullable=true, options={"fixed" = true})
103
	 */
104
	protected $countryid = '';
105
106
	/**
107
	 * @ORM\Column(name: "telephone", type: "string", length=32)
108
	 */
109
	protected $telephone = '';
110
111
	/**
112
	 * @ORM\Column(name: "telefax", type: "string", length=32)
113
	 */
114
	protected $telefax = '';
115
116
	/**
117
	 * @ORM\Column(name: "website", type: "string", length=255)
118
	 */
119
	protected $website = '';
120
121
	/**
122
	 * @ORM\Column(name: "longitude", type: "decimal", precision=8, scale=6, nullable=true)
123
	 */
124
	protected $longitude;
125
126
	/**
127
	 * @ORM\Column(name: "latitude", type: "decimal", precision=8, scale=6, nullable=true)
128
	 */
129
	protected $latitude;
130
131
	/**
132
	 * @ORM\Column(name: "birthday", type: "date", nullable=true)
133
	 */
134
	protected $birthday;
135
136
	/**
137
	 * @ORM\Column(name: "vdate", type: "date", nullable=true)
138
	 */
139
	protected $vdate;
140
141
	/**
142
	 * @ORM\Column(name: "ctime", type: "datetime", nullable=true)
143
	 */
144
	protected $ctime;
145
146
	/**
147
	 * @ORM\Column(name: "mtime", type: "datetime", nullable=true)
148
	 */
149
	protected $mtime;
150
151
	/**
152
	 * @ORM\Column(name: "editor", type: "string", length=255)
153
	 */
154
	protected $editor = '';
155
156
157
	public function __construct()
158
	{
159
		parent::__construct();
160
161
		$this->ctime = new \DateTime();
162
		$this->mtime = new \DateTime();
163
	}
164
165
166
	public function getUserIdentifier() : string
167
	{
168
		return $this->code;
0 ignored issues
show
Bug Best Practice introduced by
The property code does not exist on Aimeos\ShopBundle\Entity\FosUser. Did you maybe forget to declare it?
Loading history...
169
	}
170
171
172
	/**
173
	 * Returns the user unique ID.
174
	 *
175
	 * @return string|null
176
	 */
177
	public function getId() : ?string
178
	{
179
		return $this->id;
180
	}
181
182
183
	/**
184
	 * Returns the site ID of the user.
185
	 *
186
	 * @return mixed
187
	 */
188
	public function getSiteId() : ?string
189
	{
190
		return $this->siteid;
191
	}
192
193
194
	/**
195
	 * Returns the company name.
196
	 *
197
	 * @return string Company name
198
	 */
199
	public function getCompany() : string
200
	{
201
		return (string) $this->company;
202
	}
203
204
205
	/**
206
	 * Sets a new company name.
207
	 *
208
	 * @param string $company New company name
209
	 */
210
	public function setCompany( string $company )
211
	{
212
		$this->company = (string) $company;
213
	}
214
215
216
	/**
217
	 * Returns the vatid.
218
	 *
219
	 * @return string vatid
220
	 */
221
	public function getVatId() : string
222
	{
223
		return (string) $this->vatid;
224
	}
225
226
227
	/**
228
	 * Sets a new vatid.
229
	 *
230
	 * @param string $vatid New vatid
231
	 */
232
	public function setVatID( string $vatid )
233
	{
234
		$this->vatid = (string) $vatid;
235
	}
236
237
238
	/**
239
	 * Returns the salutation constant for the person described by the address.
240
	 *
241
	 * @return string Saluatation constant defined in \Aimeos\MShop\Common\Item\Address\Base
242
	 */
243
	public function getSalutation() : string
244
	{
245
		return $this->salutation ?? \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN;
246
	}
247
248
249
	/**
250
	 * Sets the new salutation for the person described by the address.
251
	 *
252
	 * @param string $salutation Salutation constant defined in \Aimeos\MShop\Common\Item\Address\Base
253
	 */
254
	public function setSalutation( string $salutation )
255
	{
256
		$this->salutation = $salutation;
257
	}
258
259
260
	/**
261
	 * Returns the title of the person.
262
	 *
263
	 * @return string Title of the person
264
	 */
265
	public function getTitle() : string
266
	{
267
		return (string) $this->title;
268
	}
269
270
271
	/**
272
	 * Sets a new title of the person.
273
	 *
274
	 * @param string $title New title of the person
275
	 */
276
	public function setTitle( string $title )
277
	{
278
		$this->title = $title;
279
	}
280
281
282
	/**
283
	 * Returns the first name of the person.
284
	 *
285
	 * @return string First name of the person
286
	 */
287
	public function getFirstname() : string
288
	{
289
		return (string) $this->firstname;
290
	}
291
292
293
	/**
294
	 * Sets a new first name of the person.
295
	 *
296
	 * @param string $firstname New first name of the person
297
	 */
298
	public function setFirstname( string $firstname )
299
	{
300
		$this->firstname = $firstname;
301
	}
302
303
304
	/**
305
	 * Returns the last name of the person.
306
	 *
307
	 * @return string Last name of the person
308
	 */
309
	public function getLastname() : string
310
	{
311
		return (string) $this->lastname;
312
	}
313
314
315
	/**
316
	 * Sets a new last name of the person.
317
	 *
318
	 * @param string $lastname New last name of the person
319
	 */
320
	public function setLastname( string $lastname )
321
	{
322
		$this->lastname = $lastname;
323
	}
324
325
326
	/**
327
	 * Returns the first address part, e.g. the street name.
328
	 *
329
	 * @return string First address part
330
	 */
331
	public function getAddress1() : string
332
	{
333
		return (string) $this->address1;
334
	}
335
336
337
	/**
338
	 * Sets a new first address part, e.g. the street name.
339
	 *
340
	 * @param string $address1 New first address part
341
	 */
342
	public function setAddress1( string $address1 )
343
	{
344
		$this->address1 = $address1;
345
	}
346
347
348
	/**
349
	 * Returns the second address part, e.g. the house number.
350
	 *
351
	 * @return string Second address part
352
	 */
353
	public function getAddress2() : string
354
	{
355
		return (string) $this->address2;
356
	}
357
358
359
	/**
360
	 * Sets a new second address part, e.g. the house number.
361
	 *
362
	 * @param string $address2 New second address part
363
	 */
364
	public function setAddress2( string $address2 )
365
	{
366
		$this->address2 = $address2;
367
	}
368
369
370
	/**
371
	 * Returns the third address part, e.g. the house name or floor number.
372
	 *
373
	 * @return string third address part
374
	 */
375
	public function getAddress3() : string
376
	{
377
		return (string) $this->address3;
378
	}
379
380
381
	/**
382
	 * Sets a new third address part, e.g. the house name or floor number.
383
	 *
384
	 * @param string $address3 New third address part
385
	 */
386
	public function setAddress3( string $address3 )
387
	{
388
		$this->address3 = $address3;
389
	}
390
391
392
	/**
393
	 * Returns the postal code.
394
	 *
395
	 * @return string Postal code
396
	 */
397
	public function getPostal() : string
398
	{
399
		return (string) $this->postal;
400
	}
401
402
403
	/**
404
	 * Sets a new postal code.
405
	 *
406
	 * @param string $postal New postal code
407
	 */
408
	public function setPostal( string $postal )
409
	{
410
		$this->postal = $postal;
411
	}
412
413
414
	/**
415
	 * Returns the city name.
416
	 *
417
	 * @return string City name
418
	 */
419
	public function getCity() : string
420
	{
421
		return (string) $this->city;
422
	}
423
424
425
	/**
426
	 * Sets a new city name.
427
	 *
428
	 * @param string $city New city name
429
	 */
430
	public function setCity( string $city )
431
	{
432
		$this->city = $city;
433
	}
434
435
436
	/**
437
	 * Returns the state name.
438
	 *
439
	 * @return string State name
440
	 */
441
	public function getState() : string
442
	{
443
		return (string) $this->state;
444
	}
445
446
447
	/**
448
	 * Sets a new state name.
449
	 *
450
	 * @param string $state New state name
451
	 */
452
	public function setState( string $state )
453
	{
454
		$this->state = $state;
455
	}
456
457
458
	/**
459
	 * Returns the unique ID of the country the address belongs to.
460
	 *
461
	 * @return string Unique ID of the country
462
	 */
463
	public function getCountryId() : string
464
	{
465
		return (string) $this->countryid;
466
	}
467
468
469
	/**
470
	 * Sets the ID of the country the address is in.
471
	 *
472
	 * @param string $countryid Unique ID of the country
473
	 */
474
	public function setCountryId( string $countryid )
475
	{
476
		$this->countryid = strtoupper( $countryid );
477
	}
478
479
480
	/**
481
	 * Returns the unique ID of the language.
482
	 *
483
	 * @return string Unique ID of the language
484
	 */
485
	public function getLanguageId() : string
486
	{
487
		return (string) $this->langid;
488
	}
489
490
491
	/**
492
	 * Sets the ID of the language.
493
	 *
494
	 * @param string $langid Unique ID of the language
495
	 */
496
	public function setLanguageId( string $langid )
497
	{
498
		$this->langid = $langid;
499
	}
500
501
502
	/**
503
	 * Returns the telephone number.
504
	 *
505
	 * @return string Telephone number
506
	 */
507
	public function getTelephone() : string
508
	{
509
		return (string) $this->telephone;
510
	}
511
512
513
	/**
514
	 * Sets a new telephone number.
515
	 *
516
	 * @param string $telephone New telephone number
517
	 */
518
	public function setTelephone( string $telephone )
519
	{
520
		$this->telephone = $telephone;
521
	}
522
523
524
	/**
525
	 * Returns the telefax number.
526
	 *
527
	 * @return string Telefax number
528
	 */
529
	public function getTelefax() : string
530
	{
531
		return (string) $this->telefax;
532
	}
533
534
535
	/**
536
	 * Sets a new telefax number.
537
	 *
538
	 * @param string $telefax New telefax number
539
	 */
540
	public function setTelefax( string $telefax )
541
	{
542
		$this->telefax = $telefax;
543
	}
544
545
546
	/**
547
	 * Returns the website URL.
548
	 *
549
	 * @return string Website URL
550
	 */
551
	public function getWebsite() : string
552
	{
553
		return (string) $this->website;
554
	}
555
556
557
	/**
558
	 * Sets a new website URL.
559
	 *
560
	 * @param string $website New website URL
561
	 */
562
	public function setWebsite( string $website )
563
	{
564
		$pattern = '#^([a-z]+://)?[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)+(:[0-9]+)?(/.*)?$#';
565
566
		if( $website !== '' && preg_match( $pattern, $website ) !== 1 ) {
567
			throw new \Exception( sprintf( 'Invalid web site URL "%1$s"', $website ) );
568
		}
569
570
		$this->website = $website;
571
	}
572
573
574
	/**
575
	 * Returns the longitude.
576
	 *
577
	 * @return float Longitude value
578
	 */
579
	public function getLongitude() : float
580
	{
581
		return (float) $this->longitude;
582
	}
583
584
585
	/**
586
	 * Sets a new longitude.
587
	 *
588
	 * @param float $value New longitude value
589
	 */
590
	public function setLongitude( float $value )
591
	{
592
		$this->longitude = $value;
593
	}
594
595
596
	/**
597
	 * Returns the latitude.
598
	 *
599
	 * @return float Latitude value
600
	 */
601
	public function getLatitude() : float
602
	{
603
		return (float) $this->latitude;
604
	}
605
606
607
	/**
608
	 * Sets a new latitude.
609
	 *
610
	 * @param float $value New latitude value
611
	 */
612
	public function setLatitude( float $value )
613
	{
614
		$this->latitude = $value;
615
	}
616
}
617