Completed
Push — master ( 734c2f...840a38 )
by Aimeos
03:42
created

FosUser::getSiteId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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\User
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="integer", nullable=true)
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
	/**
166
	 * Returns the user unique ID.
167
	 *
168
	 * @return mixed
169
	 */
170
	public function getId()
171
	{
172
		return $this->id;
173
	}
174
175
176
	/**
177
	 * Returns the site ID of the user.
178
	 *
179
	 * @return mixed
180
	 */
181
	public function getSiteId()
182
	{
183
		return $this->siteid;
184
	}
185
186
187
	/**
188
	 * @inheritDoc
189
	 */
190
	public function getSalt()
191
	{
192
		return $this->salt;
193
	}
194
195
196
	/**
197
	 * Returns the company name.
198
	 *
199
	 * @return string Company name
200
	 */
201
	public function getCompany()
202
	{
203
		return $this->company;
204
	}
205
206
207
	/**
208
	 * Sets a new company name.
209
	 *
210
	 * @param string $company New company name
211
	 */
212
	public function setCompany($company)
213
	{
214
		$this->company = (string) $company;
215
	}
216
217
218
	/**
219
	 * Returns the vatid.
220
	 *
221
	 * @return string vatid
222
	 */
223
	public function getVatID()
224
	{
225
		return $this->vatid;
226
	}
227
228
229
	/**
230
	 * Sets a new vatid.
231
	 *
232
	 * @param string $vatid New vatid
233
	 */
234
	public function setVatID($vatid)
235
	{
236
		$this->vatid = (string) $vatid;
237
	}
238
239
240
	/**
241
	 * Returns the salutation constant for the person described by the address.
242
	 *
243
	 * @return string Saluatation constant defined in \Aimeos\MShop\Common\Item\Address\Base
244
	 */
245
	public function getSalutation()
246
	{
247
		return ( isset( $this->salutation ) ? (string) $this->salutation : \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN );
248
	}
249
250
251
	/**
252
	 * Sets the new salutation for the person described by the address.
253
	 *
254
	 * @param string $salutation Salutation constant defined in \Aimeos\MShop\Common\Item\Address\Base
255
	 */
256
	public function setSalutation($salutation)
257
	{
258
		switch( $salutation )
259
		{
260
			case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN:
261
			case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_COMPANY:
262
			case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS:
263
			case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS:
264
			case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR:
265
				break;
266
			default:
267
				throw new \Exception( sprintf( 'Address salutation "%1$s" is unknown', $value ) );
268
		}
269
270
		$this->salutation = (string) $salutation;
271
	}
272
273
274
	/**
275
	 * Returns the title of the person.
276
	 *
277
	 * @return string Title of the person
278
	 */
279
	public function getTitle()
280
	{
281
		return $this->title;
282
	}
283
284
285
	/**
286
	 * Sets a new title of the person.
287
	 *
288
	 * @param string $title New title of the person
289
	 */
290
	public function setTitle($title)
291
	{
292
		$this->title = (string) $title;
293
	}
294
295
296
	/**
297
	 * Returns the first name of the person.
298
	 *
299
	 * @return string First name of the person
300
	 */
301
	public function getFirstname()
302
	{
303
		return $this->firstname;
304
	}
305
306
307
	/**
308
	 * Sets a new first name of the person.
309
	 *
310
	 * @param string $firstname New first name of the person
311
	 */
312
	public function setFirstname($firstname)
313
	{
314
		$this->firstname = (string) $firstname;
315
	}
316
317
318
	/**
319
	 * Returns the last name of the person.
320
	 *
321
	 * @return string Last name of the person
322
	 */
323
	public function getLastname()
324
	{
325
		return $this->lastname;
326
	}
327
328
329
	/**
330
	 * Sets a new last name of the person.
331
	 *
332
	 * @param string $lastname New last name of the person
333
	 */
334
	public function setLastname($lastname)
335
	{
336
		$this->lastname = (string) $lastname;
337
	}
338
339
340
	/**
341
	 * Returns the first address part, e.g. the street name.
342
	 *
343
	 * @return string First address part
344
	 */
345
	public function getAddress1()
346
	{
347
		return $this->address1;
348
	}
349
350
351
	/**
352
	 * Sets a new first address part, e.g. the street name.
353
	 *
354
	 * @param string $address1 New first address part
355
	 */
356
	public function setAddress1($address1)
357
	{
358
		$this->address1 = (string) $address1;
359
	}
360
361
362
	/**
363
	 * Returns the second address part, e.g. the house number.
364
	 *
365
	 * @return string Second address part
366
	 */
367
	public function getAddress2()
368
	{
369
		return $this->address2;
370
	}
371
372
373
	/**
374
	 * Sets a new second address part, e.g. the house number.
375
	 *
376
	 * @param string $address2 New second address part
377
	 */
378
	public function setAddress2($address2)
379
	{
380
		$this->address2 = (string) $address2;
381
	}
382
383
384
	/**
385
	 * Returns the third address part, e.g. the house name or floor number.
386
	 *
387
	 * @return string third address part
388
	 */
389
	public function getAddress3()
390
	{
391
		return $this->address3;
392
	}
393
394
395
	/**
396
	 * Sets a new third address part, e.g. the house name or floor number.
397
	 *
398
	 * @param string $address3 New third address part
399
	 */
400
	public function setAddress3($address3)
401
	{
402
		$this->address3 = (string) $address3;
403
	}
404
405
406
	/**
407
	 * Returns the postal code.
408
	 *
409
	 * @return string Postal code
410
	 */
411
	public function getPostal()
412
	{
413
		return $this->postal;
414
	}
415
416
417
	/**
418
	 * Sets a new postal code.
419
	 *
420
	 * @param string $postal New postal code
421
	 */
422
	public function setPostal($postal)
423
	{
424
		$this->postal = (string) $postal;
425
	}
426
427
428
	/**
429
	 * Returns the city name.
430
	 *
431
	 * @return string City name
432
	 */
433
	public function getCity()
434
	{
435
		return $this->city;
436
	}
437
438
439
	/**
440
	 * Sets a new city name.
441
	 *
442
	 * @param string $city New city name
443
	 */
444
	public function setCity($city)
445
	{
446
		$this->city = (string) $city;
447
	}
448
449
450
	/**
451
	 * Returns the state name.
452
	 *
453
	 * @return string State name
454
	 */
455
	public function getState()
456
	{
457
		return $this->state;
458
	}
459
460
461
	/**
462
	 * Sets a new state name.
463
	 *
464
	 * @param string $state New state name
465
	 */
466
	public function setState($state)
467
	{
468
		$this->state = (string) $state;
469
	}
470
471
472
	/**
473
	 * Sets the ID of the country the address is in.
474
	 *
475
	 * @param string $countryid Unique ID of the country
476
	 */
477
	public function setCountryId($countryid)
478
	{
479
		$this->countryid = strtoupper( (string) $countryid );
480
	}
481
482
483
	/**
484
	 * Returns the unique ID of the country the address belongs to.
485
	 *
486
	 * @return string Unique ID of the country
487
	 */
488
	public function getCountryId()
489
	{
490
		return $this->countryid;
491
	}
492
493
494
	/**
495
	 * Sets the ID of the language.
496
	 *
497
	 * @param string $langid Unique ID of the language
498
	 */
499
	public function setLanguageId($langid)
500
	{
501
		$this->langid = strtolower( (string) $langid );
502
	}
503
504
505
	/**
506
	 * Returns the unique ID of the language.
507
	 *
508
	 * @return string Unique ID of the language
509
	 */
510
	public function getLanguageId()
511
	{
512
		return $this->langid;
513
	}
514
515
516
	/**
517
	 * Returns the telephone number.
518
	 *
519
	 * @return string Telephone number
520
	 */
521
	public function getTelephone()
522
	{
523
		return $this->telephone;
524
	}
525
526
527
	/**
528
	 * Sets a new telephone number.
529
	 *
530
	 * @param string $telephone New telephone number
531
	 */
532
	public function setTelephone($telephone)
533
	{
534
		$this->telephone = (string) $telephone;
535
	}
536
537
538
	/**
539
	 * Returns the telefax number.
540
	 *
541
	 * @return string Telefax number
542
	 */
543
	public function getTelefax()
544
	{
545
		return $this->telefax;
546
	}
547
548
549
	/**
550
	 * Sets a new telefax number.
551
	 *
552
	 * @param string $telefax New telefax number
553
	 */
554
	public function setTelefax($telefax)
555
	{
556
		$this->telefax = (string) $telefax;
557
	}
558
559
560
	/**
561
	 * Returns the website URL.
562
	 *
563
	 * @return string Website URL
564
	 */
565
	public function getWebsite()
566
	{
567
		return $this->website;
568
	}
569
570
571
	/**
572
	 * Sets a new website URL.
573
	 *
574
	 * @param string $website New website URL
575
	 */
576
	public function setWebsite($website)
577
	{
578
		$pattern = '#^([a-z]+://)?[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)+(:[0-9]+)?(/.*)?$#';
579
580
		if( $website !== '' && preg_match( $pattern, $website ) !== 1 ) {
581
			throw new \Exception( sprintf( 'Invalid web site URL "%1$s"', $website ) );
582
		}
583
584
		$this->website = (string) $website;
585
	}
586
587
588
	/**
589
	 * Returns the longitude.
590
	 *
591
	 * @return float Longitude value
592
	 */
593
	public function getLongitude()
594
	{
595
		return $this->longitude;
596
	}
597
598
599
	/**
600
	 * Sets a new longitude.
601
	 *
602
	 * @param float $value New longitude value
603
	 */
604
	public function setLongitude($value)
605
	{
606
		$this->longitude = (float) $value;
607
	}
608
609
610
	/**
611
	 * Returns the latitude.
612
	 *
613
	 * @return Float Latitude value
614
	 */
615
	public function getLatitude()
616
	{
617
		return $this->latitude;
618
	}
619
620
621
	/**
622
	 * Sets a new latitude.
623
	 *
624
	 * @param float $value New latitude value
625
	 */
626
	public function setLatitude($value)
627
	{
628
		$this->latitude = (float) $value;
629
	}
630
}
631