Passed
Push — master ( 2b9795...8c3433 )
by Aimeos
07:40
created

Standard::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2015-2024
7
 * @package MShop
8
 * @subpackage Order
9
 */
10
11
12
namespace Aimeos\MShop\Order\Item\Address;
13
14
15
/**
16
 * Default order address container object
17
 *
18
 * @package MShop
19
 * @subpackage Order
20
 */
21
class Standard
22
	extends \Aimeos\MShop\Order\Item\Address\Base
23
	implements \Aimeos\MShop\Order\Item\Address\Iface
24
{
25
	/**
26
	 * Returns the original customer address ID.
27
	 *
28
	 * @return string Customer address ID
29
	 */
30
	public function getAddressId() : string
31
	{
32
		return $this->get( 'order.address.addressid', '' );
33
	}
34
35
36
	/**
37
	 * Sets the original customer address ID.
38
	 *
39
	 * @param string $addrid New customer address ID
40
	 * @return \Aimeos\MShop\Order\Item\Address\Iface Order base address item for chaining method calls
41
	 */
42
	public function setAddressId( string $addrid ) : \Aimeos\MShop\Order\Item\Address\Iface
43
	{
44
		return $this->set( 'order.address.addressid', $addrid );
45
	}
46
47
48
	/**
49
	 * Copys all data from a given address item.
50
	 *
51
	 * @param \Aimeos\MShop\Common\Item\Address\Iface $item New address
52
	 * @return \Aimeos\MShop\Order\Item\Address\Iface Order base address item for chaining method calls
53
	 */
54
	public function copyFrom( \Aimeos\MShop\Common\Item\Address\Iface $item ) : \Aimeos\MShop\Common\Item\Address\Iface
55
	{
56
		if( self::macro( 'copyFrom' ) ) {
57
			return $this->call( 'copyFrom', $item );
58
		}
59
60
		parent::copyFrom( $item );
61
62
		$this->setAddressId( (string) $item->getId() );
63
		$this->setModified();
64
65
		return $this;
66
	}
67
68
69
	/*
70
	 * Sets the item values from the given array and removes that entries from the list
71
	 *
72
	 * @param array &$list Associative list of item keys and their values
73
	 * @param bool True to set private properties too, false for public only
74
	 * @return \Aimeos\MShop\Order\Item\Address\Iface Order address item for chaining method calls
75
	 */
76
	public function fromArray( array &$list, bool $private = false ) : \Aimeos\MShop\Common\Item\Iface
77
	{
78
		$item = parent::fromArray( $list, $private );
79
80
		foreach( $list as $key => $value )
81
		{
82
			switch( $key )
83
			{
84
				case 'order.address.addressid': $item = $item->setAddressId( $value ); break;
0 ignored issues
show
Bug introduced by
The method setAddressId() does not exist on Aimeos\MShop\Common\Item\Address\Base. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

84
				case 'order.address.addressid': /** @scrutinizer ignore-call */ $item = $item->setAddressId( $value ); break;
Loading history...
85
				default: continue 2;
86
			}
87
88
			unset( $list[$key] );
89
		}
90
91
		return $item;
92
	}
93
94
95
	/**
96
	 * Returns the item values as array.
97
	 *
98
	 * @param bool True to return private properties, false for public only
99
	 * @return array Associative list of item properties and their values
100
	 */
101
	public function toArray( bool $private = false ) : array
102
	{
103
		$list = parent::toArray( $private );
104
105
		$list['order.address.addressid'] = $this->getAddressId();
106
107
		return $list;
108
	}
109
110
}
111