Completed
Push — master ( 7cc8ce...2bcb4b )
by Aimeos
16:15
created

FosUser::setLongitude()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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