Completed
Push — 2016.07 ( d1403d...67f8f7 )
by Aimeos
02:58
created

Typo3::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 6
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016
6
 * @package MShop
7
 * @subpackage Customer
8
 */
9
10
11
namespace Aimeos\MShop\Customer\Item;
12
13
14
/**
15
 * TYPO3 customer objects used by the shop
16
 *
17
 * @package MShop
18
 * @subpackage Customer
19
 */
20
class Typo3 extends Standard implements Iface
21
{
22
	private $values;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
23
24
25
	/**
26
	 * Initializes the customer item object
27
	 *
28
	 * @param \Aimeos\MShop\Common\Item\Address\Iface $address Payment address item object
29
	 * @param array $values List of attributes that belong to the customer item
30
	 * @param \Aimeos\MShop\Common\Lists\Item\Iface[] $listItems List of list items
31
	 * @param \Aimeos\MShop\Common\Item\Iface[] $refItems List of referenced items
32
	 * @param string $salt Password salt (optional)
33
	 * @param \Aimeos\MShop\Common\Item\Helper\Password\Iface|null $helper Password encryption helper object
34
	 */
35
	public function __construct( \Aimeos\MShop\Common\Item\Address\Iface $address, array $values = array(),
36
		array $listItems = array(), array $refItems = array(), $salt = '',
37
		\Aimeos\MShop\Common\Item\Helper\Password\Iface $helper = null )
38
	{
39
		parent::__construct( $address, $values, $listItems, $refItems );
40
41
		$this->values = $values;
42
	}
43
44
45
	/**
46
	 * Returns the TYPO3 page ID of the user
47
	 *
48
	 * @return integer Page ID of the user
49
	 */
50
	public function getPageId()
51
	{
52
		if( isset( $this->values['typo3.pageid'] ) ) {
53
			return (int) $this->values['typo3.pageid'];
54
		}
55
56
		return 0;
57
	}
58
59
60
	/**
61
	 * Sets the TYPO3 page ID for the user
62
	 *
63
	 * @param integer $value Page ID of the user
64
	 * @return \Aimeos\MShop\Customer\Item\Iface Customer item for chaining method calls
65
	 */
66
	public function setPageId( $value )
67
	{
68
		if( $value == $this->getPageId() ) { return $this; }
69
70
		$this->values['typo3.pageid'] = (int) $value;
71
		$this->setModified();
72
73
		return $this;
74
	}
75
76
77
	/**
78
	 * Sets the item values from the given array.
79
	 *
80
	 * @param array $list Associative list of item keys and their values
81
	 * @return array Associative list of keys and their values that are unknown
82
	 */
83
	public function fromArray( array $list )
84
	{
85
		$unknown = array();
86
		$list = parent::fromArray( $list );
87
88
		foreach( $list as $key => $value )
89
		{
90
			switch( $key )
91
			{
92
				case 'typo3.pageid': $this->setPageId( $value ); break;
93
				default: $unknown[$key] = $value;
94
			}
95
		}
96
97
		return $unknown;
98
	}
99
100
101
	/**
102
	 * Returns the item values as array.
103
	 *
104
	 * @return array Associative list of item properties and their values
105
	 */
106
	public function toArray()
107
	{
108
		$list = parent::toArray();
109
		$list['typo3.pageid'] = $this->getPageId();
110
111
		return $list;
112
	}
113
}
114