Passed
Push — master ( 3311dc...3c99d6 )
by Aimeos
05:26
created

mshoplib/src/MShop/Common/Item/Address/Base.php (1 issue)

1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2015-2018
7
 * @package MShop
8
 * @subpackage Common
9
 */
10
11
12
namespace Aimeos\MShop\Common\Item\Address;
13
14
15
/**
16
 * Abstract class for address items.
17
 *
18
 * @package MShop
19
 * @subpackage Common
20
 */
21
abstract class Base
22
	extends \Aimeos\MShop\Common\Item\Base
23
	implements \Aimeos\MShop\Common\Item\Address\Iface
24
{
25
	/**
26
	 * Saluation is not known.
27
	 * The customer didn't choose a valid salutation.
28
	 */
29
	const SALUTATION_UNKNOWN = '';
30
31
	/**
32
	 * Saluation for a company.
33
	 */
34
	const SALUTATION_COMPANY = 'company';
35
36
	/**
37
	 * Saluation for a female customer.
38
	 */
39
	const SALUTATION_MRS = 'mrs';
40
41
	/**
42
	 * Saluation for a female customer (not maried, usually not used any more).
43
	 */
44
	const SALUTATION_MISS = 'miss';
45
46
	/**
47
	 * Saluation for a male customer.
48
	 */
49
	const SALUTATION_MR = 'mr';
50
51
	private $prefix;
52
	private $data;
53
54
55
	/**
56
	 * Initializes the address item.
57
	 *
58
	 * @param string $prefix Key prefix that should be used for toArray()/fromArray() like "customer.address."
59
	 * @param array $values Associative list of key/value pairs containing address data
60
	 */
61
	public function __construct( $prefix, array $values )
62
	{
63
		parent::__construct( $prefix, $values );
64
65
		$this->data = $values;
66
		$this->prefix = $prefix;
67
	}
68
69
70
71
72
	/**
73
	 * Returns the company name.
74
	 *
75
	 * @return string Company name
76
	 */
77
	public function getCompany()
78
	{
79
		if( isset( $this->data[$this->prefix . 'company'] ) ) {
80
			return (string) $this->data[$this->prefix . 'company'];
81
		}
82
83
		return '';
84
	}
85
86
87
	/**
88
	 * Sets a new company name.
89
	 *
90
	 * @param string $company New company name
91
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
92
	 */
93
	public function setCompany( $company )
94
	{
95
		if( (string) $company !== $this->getCompany() )
96
		{
97
			$this->data[$this->prefix . 'company'] = (string) $company;
98
			$this->setModified();
99
		}
100
101
		return $this;
102
	}
103
104
	/**
105
	 * Returns the vatid.
106
	 *
107
	 * @return string vatid
108
	 */
109
	public function getVatID()
0 ignored issues
show
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
110
	{
111
		if( isset( $this->data[$this->prefix . 'vatid'] ) ) {
112
			return (string) $this->data[$this->prefix . 'vatid'];
113
		}
114
115
		return '';
116
	}
117
118
119
	/**
120
	 * Sets a new vatid.
121
	 *
122
	 * @param string $vatid New vatid
123
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
124
	 */
125
	public function setVatID( $vatid )
126
	{
127
		if( (string) $vatid !== $this->getVatID() )
128
		{
129
			$this->data[$this->prefix . 'vatid'] = (string) $vatid;
130
			$this->setModified();
131
		}
132
133
		return $this;
134
	}
135
136
137
	/**
138
	 * Returns the salutation constant for the person described by the address.
139
	 *
140
	 * @return string Saluatation constant defined in \Aimeos\MShop\Common\Item\Address\Base
141
	 */
142
	public function getSalutation()
143
	{
144
		if( isset( $this->data[$this->prefix . 'salutation'] ) ) {
145
			return (string) $this->data[$this->prefix . 'salutation'];
146
		}
147
148
		return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN;
149
	}
150
151
152
	/**
153
	 * Sets the new salutation for the person described by the address.
154
	 *
155
	 * @param string $salutation Salutation constant defined in \Aimeos\MShop\Common\Item\Address\Base
156
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
157
	 */
158
	public function setSalutation( $salutation )
159
	{
160
		$this->checkSalutation( $salutation );
161
162
		if( (string) $salutation !== $this->getSalutation() )
163
		{
164
			$this->data[$this->prefix . 'salutation'] = (string) $salutation;
165
			$this->setModified();
166
		}
167
168
		return $this;
169
	}
170
171
172
	/**
173
	 * Returns the title of the person.
174
	 *
175
	 * @return string Title of the person
176
	 */
177
	public function getTitle()
178
	{
179
		if( isset( $this->data[$this->prefix . 'title'] ) ) {
180
			return (string) $this->data[$this->prefix . 'title'];
181
		}
182
183
		return '';
184
	}
185
186
187
	/**
188
	 * Sets a new title of the person.
189
	 *
190
	 * @param string $title New title of the person
191
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
192
	 */
193
	public function setTitle( $title )
194
	{
195
		if( (string) $title !== $this->getTitle() )
196
		{
197
			$this->data[$this->prefix . 'title'] = (string) $title;
198
			$this->setModified();
199
		}
200
201
		return $this;
202
	}
203
204
205
	/**
206
	 * Returns the first name of the person.
207
	 *
208
	 * @return string First name of the person
209
	 */
210
	public function getFirstname()
211
	{
212
		if( isset( $this->data[$this->prefix . 'firstname'] ) ) {
213
			return (string) $this->data[$this->prefix . 'firstname'];
214
		}
215
216
		return '';
217
	}
218
219
220
	/**
221
	 * Sets a new first name of the person.
222
	 *
223
	 * @param string $firstname New first name of the person
224
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
225
	 */
226
	public function setFirstname( $firstname )
227
	{
228
		if( (string) $firstname !== $this->getFirstname() )
229
		{
230
			$this->data[$this->prefix . 'firstname'] = (string) $firstname;
231
			$this->setModified();
232
		}
233
234
		return $this;
235
	}
236
237
238
	/**
239
	 * Returns the last name of the person.
240
	 *
241
	 * @return string Last name of the person
242
	 */
243
	public function getLastname()
244
	{
245
		if( isset( $this->data[$this->prefix . 'lastname'] ) ) {
246
			return (string) $this->data[$this->prefix . 'lastname'];
247
		}
248
249
		return '';
250
	}
251
252
253
	/**
254
	 * Sets a new last name of the person.
255
	 *
256
	 * @param string $lastname New last name of the person
257
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
258
	 */
259
	public function setLastname( $lastname )
260
	{
261
		if( (string) $lastname !== $this->getLastname() )
262
		{
263
			$this->data[$this->prefix . 'lastname'] = (string) $lastname;
264
			$this->setModified();
265
		}
266
267
		return $this;
268
	}
269
270
271
	/**
272
	 * Returns the first address part, e.g. the street name.
273
	 *
274
	 * @return string First address part
275
	 */
276
	public function getAddress1()
277
	{
278
		if( isset( $this->data[$this->prefix . 'address1'] ) ) {
279
			return (string) $this->data[$this->prefix . 'address1'];
280
		}
281
282
		return '';
283
	}
284
285
286
	/**
287
	 * Sets a new first address part, e.g. the street name.
288
	 *
289
	 * @param string $address1 New first address part
290
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
291
	 */
292
	public function setAddress1( $address1 )
293
	{
294
		if( (string) $address1 !== $this->getAddress1() )
295
		{
296
			$this->data[$this->prefix . 'address1'] = (string) $address1;
297
			$this->setModified();
298
		}
299
300
		return $this;
301
	}
302
303
304
	/**
305
	 * Returns the second address part, e.g. the house number.
306
	 *
307
	 * @return string Second address part
308
	 */
309
	public function getAddress2()
310
	{
311
		if( isset( $this->data[$this->prefix . 'address2'] ) ) {
312
			return (string) $this->data[$this->prefix . 'address2'];
313
		}
314
315
		return '';
316
	}
317
318
319
	/**
320
	 * Sets a new second address part, e.g. the house number.
321
	 *
322
	 * @param string $address2 New second address part
323
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
324
	 */
325
	public function setAddress2( $address2 )
326
	{
327
		if( (string) $address2 !== $this->getAddress2() )
328
		{
329
			$this->data[$this->prefix . 'address2'] = (string) $address2;
330
			$this->setModified();
331
		}
332
333
		return $this;
334
	}
335
336
337
	/**
338
	 * Returns the third address part, e.g. the house name or floor number.
339
	 *
340
	 * @return string third address part
341
	 */
342
	public function getAddress3()
343
	{
344
		if( isset( $this->data[$this->prefix . 'address3'] ) ) {
345
			return (string) $this->data[$this->prefix . 'address3'];
346
		}
347
348
		return '';
349
	}
350
351
352
	/**
353
	 * Sets a new third address part, e.g. the house name or floor number.
354
	 *
355
	 * @param string $address3 New third address part
356
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
357
	 */
358
	public function setAddress3( $address3 )
359
	{
360
		if( (string) $address3 !== $this->getAddress3() )
361
		{
362
			$this->data[$this->prefix . 'address3'] = (string) $address3;
363
			$this->setModified();
364
		}
365
366
		return $this;
367
	}
368
369
370
	/**
371
	 * Returns the postal code.
372
	 *
373
	 * @return string Postal code
374
	 */
375
	public function getPostal()
376
	{
377
		if( isset( $this->data[$this->prefix . 'postal'] ) ) {
378
			return (string) $this->data[$this->prefix . 'postal'];
379
		}
380
381
		return '';
382
	}
383
384
385
	/**
386
	 * Sets a new postal code.
387
	 *
388
	 * @param string $postal New postal code
389
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
390
	 */
391
	public function setPostal( $postal )
392
	{
393
		if( (string) $postal !== $this->getPostal() )
394
		{
395
			$this->data[$this->prefix . 'postal'] = (string) $postal;
396
			$this->setModified();
397
		}
398
399
		return $this;
400
	}
401
402
403
	/**
404
	 * Returns the city name.
405
	 *
406
	 * @return string City name
407
	 */
408
	public function getCity()
409
	{
410
		if( isset( $this->data[$this->prefix . 'city'] ) ) {
411
			return (string) $this->data[$this->prefix . 'city'];
412
		}
413
414
		return '';
415
	}
416
417
418
	/**
419
	 * Sets a new city name.
420
	 *
421
	 * @param string $city New city name
422
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
423
	 */
424
	public function setCity( $city )
425
	{
426
		if( (string) $city !== $this->getCity() )
427
		{
428
			$this->data[$this->prefix . 'city'] = (string) $city;
429
			$this->setModified();
430
		}
431
432
		return $this;
433
	}
434
435
436
	/**
437
	 * Returns the state name.
438
	 *
439
	 * @return string State name
440
	 */
441
	public function getState()
442
	{
443
		if( isset( $this->data[$this->prefix . 'state'] ) ) {
444
			return (string) $this->data[$this->prefix . 'state'];
445
		}
446
447
		return '';
448
	}
449
450
451
	/**
452
	 * Sets a new state name.
453
	 *
454
	 * @param string $state New state name
455
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
456
	 */
457
	public function setState( $state )
458
	{
459
		if( (string) $state !== $this->getState() )
460
		{
461
			$this->data[$this->prefix . 'state'] = (string) $state;
462
			$this->setModified();
463
		}
464
465
		return $this;
466
	}
467
468
469
	/**
470
	 * Returns the unique ID of the country the address belongs to.
471
	 *
472
	 * @return string|null Unique ID of the country
473
	 */
474
	public function getCountryId()
475
	{
476
		if( isset( $this->data[$this->prefix . 'countryid'] ) ) {
477
			return (string) $this->data[$this->prefix . 'countryid'];
478
		}
479
480
		return null;
481
	}
482
483
484
	/**
485
	 * Sets the ID of the country the address is in.
486
	 *
487
	 * @param string $countryid Unique ID of the country
488
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
489
	 */
490
	public function setCountryId( $countryid )
491
	{
492
		if( $countryid !== $this->getCountryId() )
493
		{
494
			$this->data[$this->prefix . 'countryid'] = $this->checkCountryId( $countryid );
495
			$this->setModified();
496
		}
497
498
		return $this;
499
	}
500
501
502
	/**
503
	 * Returns the unique ID of the language.
504
	 *
505
	 * @return string|null Unique ID of the language
506
	 */
507
	public function getLanguageId()
508
	{
509
		if( isset( $this->data[$this->prefix . 'languageid'] ) ) {
510
			return (string) $this->data[$this->prefix . 'languageid'];
511
		}
512
513
		return null;
514
	}
515
516
517
	/**
518
	 * Sets the ID of the language.
519
	 *
520
	 * @param string $langid Unique ID of the language
521
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
522
	 */
523
	public function setLanguageId( $langid )
524
	{
525
		if( $langid !== $this->getLanguageId() )
526
		{
527
			$this->data[$this->prefix . 'languageid'] = $this->checkLanguageId( $langid );
528
			$this->setModified();
529
		}
530
531
		return $this;
532
	}
533
534
535
	/**
536
	 * Returns the telephone number.
537
	 *
538
	 * @return string Telephone number
539
	 */
540
	public function getTelephone()
541
	{
542
		if( isset( $this->data[$this->prefix . 'telephone'] ) ) {
543
			return (string) $this->data[$this->prefix . 'telephone'];
544
		}
545
546
		return '';
547
	}
548
549
550
	/**
551
	 * Sets a new telephone number.
552
	 *
553
	 * @param string $telephone New telephone number
554
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
555
	 */
556
	public function setTelephone( $telephone )
557
	{
558
		if( (string) $telephone !== $this->getTelephone() )
559
		{
560
			$this->data[$this->prefix . 'telephone'] = (string) $telephone;
561
			$this->setModified();
562
		}
563
564
		return $this;
565
	}
566
567
568
	/**
569
	 * Returns the email address.
570
	 *
571
	 * @return string Email address
572
	 */
573
	public function getEmail()
574
	{
575
		if( isset( $this->data[$this->prefix . 'email'] ) ) {
576
			return (string) $this->data[$this->prefix . 'email'];
577
		}
578
579
		return '';
580
	}
581
582
583
	/**
584
	 * Sets a new email address.
585
	 *
586
	 * @param string $email New email address
587
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
588
	 */
589
	public function setEmail( $email )
590
	{
591
		if( $email != '' && preg_match( '/^.+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*$/', $email ) !== 1 ) {
592
			throw new \Aimeos\MShop\Exception( sprintf( 'Invalid characters in email address: "%1$s"', $email ) );
593
		}
594
595
		if( (string) $email !== $this->getEmail() )
596
		{
597
			$this->data[$this->prefix . 'email'] = (string) $email;
598
			$this->setModified();
599
		}
600
601
		return $this;
602
	}
603
604
605
	/**
606
	 * Returns the telefax number.
607
	 *
608
	 * @return string Telefax number
609
	 */
610
	public function getTelefax()
611
	{
612
		if( isset( $this->data[$this->prefix . 'telefax'] ) ) {
613
			return (string) $this->data[$this->prefix . 'telefax'];
614
		}
615
616
		return '';
617
	}
618
619
620
	/**
621
	 * Sets a new telefax number.
622
	 *
623
	 * @param string $telefax New telefax number
624
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
625
	 */
626
	public function setTelefax( $telefax )
627
	{
628
		if( (string) $telefax !== $this->getTelefax() )
629
		{
630
			$this->data[$this->prefix . 'telefax'] = (string) $telefax;
631
			$this->setModified();
632
		}
633
634
		return $this;
635
	}
636
637
638
	/**
639
	 * Returns the website URL.
640
	 *
641
	 * @return string Website URL
642
	 */
643
	public function getWebsite()
644
	{
645
		if( isset( $this->data[$this->prefix . 'website'] ) ) {
646
			return (string) $this->data[$this->prefix . 'website'];
647
		}
648
649
		return '';
650
	}
651
652
653
	/**
654
	 * Sets a new website URL.
655
	 *
656
	 * @param string|null $website New website URL
657
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
658
	 */
659
	public function setWebsite( $website )
660
	{
661
		$pattern = '#^([a-z]+://)?[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)+(:[0-9]+)?(/.*)?$#';
662
663
		if( $website != '' && preg_match( $pattern, $website ) !== 1 ) {
664
			throw new \Aimeos\MShop\Exception( sprintf( 'Invalid web site URL "%1$s"', $website ) );
665
		}
666
667
		if( (string) $website !== $this->getWebsite() )
668
		{
669
			$this->data[$this->prefix . 'website'] = (string) $website;
670
			$this->setModified();
671
		}
672
673
		return $this;
674
	}
675
676
677
	/**
678
	 * Returns the longitude coordinate of the customer address
679
	 *
680
	 * @return float|null Longitude coordinate as decimal value or null
681
	 */
682
	public function getLongitude()
683
	{
684
		if( isset( $this->data[$this->prefix . 'longitude'] ) ) {
685
			return (float) $this->data[$this->prefix . 'longitude'];
686
		}
687
688
		return null;
689
	}
690
691
692
	/**
693
	 * Sets the longitude coordinate of the customer address
694
	 *
695
	 * @param float|null $value Longitude coordinate as decimal value or null
696
	 * @return \Aimeos\MShop\Customer\Item\Iface Customer item for chaining method calls
697
	 */
698
	public function setLongitude( $value )
699
	{
700
		if( $value === '' ) { $value = null; }
701
702
		if( $value !== $this->getLongitude() )
703
		{
704
			$this->data[$this->prefix . 'longitude'] = (float) $value;
705
			$this->setModified();
706
		}
707
708
		return $this;
709
	}
710
711
712
	/**
713
	 * Returns the latitude coordinate of the customer address
714
	 *
715
	 * @return float|null Latitude coordinate as decimal value or null
716
	 */
717
	public function getLatitude()
718
	{
719
		if( isset( $this->data[$this->prefix . 'latitude'] ) ) {
720
			return (float) $this->data[$this->prefix . 'latitude'];
721
		}
722
723
		return null;
724
	}
725
726
727
	/**
728
	 * Sets the latitude coordinate of the customer address
729
	 *
730
	 * @param float|null $value Latitude coordinate as decimal value or null
731
	 * @return \Aimeos\MShop\Customer\Item\Iface Customer item for chaining method calls
732
	 */
733
	public function setLatitude( $value )
734
	{
735
		if( $value === '' ) { $value = null; }
736
737
		if( $value !== $this->getLatitude() )
738
		{
739
			$this->data[$this->prefix . 'latitude'] = (float) $value;
740
			$this->setModified();
741
		}
742
743
		return $this;
744
	}
745
746
747
	/**
748
	 * Returns the item type
749
	 *
750
	 * @return string Item type, subtypes are separated by slashes
751
	 */
752
	public function getResourceType()
753
	{
754
		return str_replace( '.', '/', rtrim( $this->prefix, '.' ) );
755
	}
756
757
758
	/**
759
	 * Copies the values of the address item into another one.
760
	 *
761
	 * @param \Aimeos\MShop\Common\Item\Address\Iface $item Address item
762
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Common address item for chaining method calls
763
	 */
764
	public function copyFrom( \Aimeos\MShop\Common\Item\Address\Iface $item )
765
	{
766
		$this->setCompany( $item->getCompany() );
767
		$this->setVatID( $item->getVatID() );
768
		$this->setSalutation( $item->getSalutation() );
769
		$this->setTitle( $item->getTitle() );
770
		$this->setFirstname( $item->getFirstname() );
771
		$this->setLastname( $item->getLastname() );
772
		$this->setAddress1( $item->getAddress1() );
773
		$this->setAddress2( $item->getAddress2() );
774
		$this->setAddress3( $item->getAddress3() );
775
		$this->setPostal( $item->getPostal() );
776
		$this->setCity( $item->getCity() );
777
		$this->setState( $item->getState() );
778
		$this->setCountryId( $item->getCountryId() );
779
		$this->setLanguageId( $item->getLanguageId() );
780
		$this->setTelephone( $item->getTelephone() );
781
		$this->setTelefax( $item->getTelefax() );
782
		$this->setEmail( $item->getEmail() );
783
		$this->setWebsite( $item->getWebsite() );
784
		$this->setLongitude( $item->getLongitude() );
785
		$this->setLatitude( $item->getLatitude() );
786
787
		$this->setModified();
788
789
		return $this;
790
	}
791
792
793
	/*
794
	 * Sets the item values from the given array and removes that entries from the list
795
	 *
796
	 * @param array &$list Associative list of item keys and their values
797
	 * @param boolean True to set private properties too, false for public only
798
	 * @return \Aimeos\MShop\Common\Item\Address\Iface Address item for chaining method calls
799
	 */
800
	public function fromArray( array &$list, $private = false )
801
	{
802
		$item = parent::fromArray( $list, $private );
803
804
		foreach( $list as $key => $value )
805
		{
806
			$key = str_replace( 'order.base.address.', $this->prefix, $key );
807
808
			switch( $key )
809
			{
810
				case $this->prefix . 'salutation': $item = $item->setSalutation( $value ); break;
811
				case $this->prefix . 'company': $item = $item->setCompany( $value ); break;
812
				case $this->prefix . 'vatid': $item = $item->setVatID( $value ); break;
813
				case $this->prefix . 'title': $item = $item->setTitle( $value ); break;
814
				case $this->prefix . 'firstname': $item = $item->setFirstname( $value ); break;
815
				case $this->prefix . 'lastname': $item = $item->setLastname( $value ); break;
816
				case $this->prefix . 'address1': $item = $item->setAddress1( $value ); break;
817
				case $this->prefix . 'address2': $item = $item->setAddress2( $value ); break;
818
				case $this->prefix . 'address3': $item = $item->setAddress3( $value ); break;
819
				case $this->prefix . 'postal': $item = $item->setPostal( $value ); break;
820
				case $this->prefix . 'city': $item = $item->setCity( $value ); break;
821
				case $this->prefix . 'state': $item = $item->setState( $value ); break;
822
				case $this->prefix . 'countryid': $item = $item->setCountryId( $value ); break;
823
				case $this->prefix . 'languageid': $item = $item->setLanguageId( $value ); break;
824
				case $this->prefix . 'telephone': $item = $item->setTelephone( $value ); break;
825
				case $this->prefix . 'telefax': $item = $item->setTelefax( $value ); break;
826
				case $this->prefix . 'email': $item = $item->setEmail( $value ); break;
827
				case $this->prefix . 'website': $item = $item->setWebsite( $value ); break;
828
				case $this->prefix . 'longitude': $item = $item->setLongitude( $value ); break;
829
				case $this->prefix . 'latitude': $item = $item->setLatitude( $value ); break;
830
				default: continue 2;
831
			}
832
833
			unset( $list[$key] );
834
		}
835
836
		return $item;
837
	}
838
839
840
	/**
841
	 * Returns the item values as array.
842
	 *
843
	 * @param boolean True to return private properties, false for public only
844
	 * @return array Associative list of item properties and their values
845
	 */
846
	public function toArray( $private = false )
847
	{
848
		$list = parent::toArray( $private );
849
850
		$list[$this->prefix . 'salutation'] = $this->getSalutation();
851
		$list[$this->prefix . 'company'] = $this->getCompany();
852
		$list[$this->prefix . 'vatid'] = $this->getVatID();
853
		$list[$this->prefix . 'title'] = $this->getTitle();
854
		$list[$this->prefix . 'firstname'] = $this->getFirstname();
855
		$list[$this->prefix . 'lastname'] = $this->getLastname();
856
		$list[$this->prefix . 'address1'] = $this->getAddress1();
857
		$list[$this->prefix . 'address2'] = $this->getAddress2();
858
		$list[$this->prefix . 'address3'] = $this->getAddress3();
859
		$list[$this->prefix . 'postal'] = $this->getPostal();
860
		$list[$this->prefix . 'city'] = $this->getCity();
861
		$list[$this->prefix . 'state'] = $this->getState();
862
		$list[$this->prefix . 'countryid'] = $this->getCountryId();
863
		$list[$this->prefix . 'languageid'] = $this->getLanguageId();
864
		$list[$this->prefix . 'telephone'] = $this->getTelephone();
865
		$list[$this->prefix . 'telefax'] = $this->getTelefax();
866
		$list[$this->prefix . 'email'] = $this->getEmail();
867
		$list[$this->prefix . 'website'] = $this->getWebsite();
868
		$list[$this->prefix . 'longitude'] = $this->getLongitude();
869
		$list[$this->prefix . 'latitude'] = $this->getLatitude();
870
871
		return $list;
872
	}
873
874
875
	/**
876
	 * Checks the given address salutation is valid
877
	 *
878
	 * @param string $value Address salutation defined in \Aimeos\MShop\Common\Item\Address\Base
879
	 * @throws \Aimeos\MShop\Common\Exception If salutation is invalid
880
	 */
881
	protected function checkSalutation( $value )
882
	{
883
		switch( $value )
884
		{
885
			case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_UNKNOWN:
886
			case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_COMPANY:
887
			case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS:
888
			case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS:
889
			case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR:
890
				return $value;
891
		}
892
893
		throw new \Aimeos\MShop\Exception( sprintf( 'Address salutation "%1$s" not within allowed range', $value ) );
894
	}
895
}
896