Passed
Push — master ( 3c3bea...36cb3b )
by Aimeos
17:26
created

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