Completed
Push — master ( 5e3755...9505fd )
by Aimeos
02:12
created
controller/frontend/tests/Controller/Frontend/Customer/StandardTest.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -18,124 +18,124 @@  discard block
 block discarded – undo
18 18
 	protected function setUp()
19 19
 	{
20 20
 		$this->context = \TestHelperFrontend::getContext();
21
-		$this->object = new \Aimeos\Controller\Frontend\Customer\Standard( $this->context );
21
+		$this->object = new \Aimeos\Controller\Frontend\Customer\Standard($this->context);
22 22
 	}
23 23
 
24 24
 
25 25
 	protected function tearDown()
26 26
 	{
27
-		unset( $this->context, $this->object );
27
+		unset($this->context, $this->object);
28 28
 	}
29 29
 
30 30
 
31 31
 	public function testAddEditSaveDeleteItem()
32 32
 	{
33
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' );
34
-		$id = $manager->findItem( 'UTC001' )->getId();
33
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer');
34
+		$id = $manager->findItem('UTC001')->getId();
35 35
 
36
-		$this->context->setUserId( $id );
37
-		$item = $this->object->addItem( ['customer.code' => 'unittest-ctnl', 'customer.status' => 1] );
38
-		$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item );
36
+		$this->context->setUserId($id);
37
+		$item = $this->object->addItem(['customer.code' => 'unittest-ctnl', 'customer.status' => 1]);
38
+		$this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item);
39 39
 
40
-		$this->context->setUserId( $item->getId() );
41
-		$item = $this->object->editItem( $item->getId(), ['customer.code' => 'unittest-ctnl2'] );
42
-		$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item );
40
+		$this->context->setUserId($item->getId());
41
+		$item = $this->object->editItem($item->getId(), ['customer.code' => 'unittest-ctnl2']);
42
+		$this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item);
43 43
 
44
-		$item->setStatus( 0 );
45
-		$item = $this->object->saveItem( $item );
46
-		$this->assertEquals( 0, $item->getStatus() );
44
+		$item->setStatus(0);
45
+		$item = $this->object->saveItem($item);
46
+		$this->assertEquals(0, $item->getStatus());
47 47
 
48
-		$this->object->deleteItem( $item->getId() );
48
+		$this->object->deleteItem($item->getId());
49 49
 
50
-		$this->setExpectedException( '\Aimeos\MShop\Exception' );
51
-		$manager->findItem( 'unittest-ctnl' );
50
+		$this->setExpectedException('\Aimeos\MShop\Exception');
51
+		$manager->findItem('unittest-ctnl');
52 52
 	}
53 53
 
54 54
 
55 55
 	public function testAddExistingItem()
56 56
 	{
57
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' );
58
-		$id = $manager->findItem( 'UTC001' )->getId();
57
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer');
58
+		$id = $manager->findItem('UTC001')->getId();
59 59
 
60
-		$item = $this->object->addItem( ['customer.code' => 'UTC001'] );
61
-		$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item );
60
+		$item = $this->object->addItem(['customer.code' => 'UTC001']);
61
+		$this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item);
62 62
 	}
63 63
 
64 64
 
65 65
 	public function testCreateItem()
66 66
 	{
67 67
 		$result = $this->object->createItem();
68
-		$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result );
68
+		$this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result);
69 69
 	}
70 70
 
71 71
 
72 72
 	public function testGetItem()
73 73
 	{
74
-		$id = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' )->getId();
75
-		$this->context->setUserId( $id );
74
+		$id = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001')->getId();
75
+		$this->context->setUserId($id);
76 76
 
77
-		$result = $this->object->getItem( $id, ['customer/address', 'text'] );
77
+		$result = $this->object->getItem($id, ['customer/address', 'text']);
78 78
 
79
-		$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result );
80
-		$this->assertEquals( 1, count( $result->getRefItems( 'text' ) ) );
81
-		$this->assertEquals( 1, count( $result->getAddressItems() ) );
79
+		$this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result);
80
+		$this->assertEquals(1, count($result->getRefItems('text')));
81
+		$this->assertEquals(1, count($result->getAddressItems()));
82 82
 	}
83 83
 
84 84
 
85 85
 	public function testFindItem()
86 86
 	{
87
-		$result = $this->object->findItem( 'UTC001' );
88
-		$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result );
87
+		$result = $this->object->findItem('UTC001');
88
+		$this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result);
89 89
 	}
90 90
 
91 91
 
92 92
 	public function testAddEditSaveDeleteAddressItem()
93 93
 	{
94
-		$customer = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' );
95
-		$this->context->setUserId( $customer->getId() );
94
+		$customer = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001');
95
+		$this->context->setUserId($customer->getId());
96 96
 
97
-		$item = $this->object->addAddressItem( ['customer.address.lastname' => 'unittest-ctnl'] );
98
-		$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $item );
97
+		$item = $this->object->addAddressItem(['customer.address.lastname' => 'unittest-ctnl']);
98
+		$this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $item);
99 99
 
100
-		$item = $this->object->editAddressItem( $item->getId(), ['customer.address.lastname' => 'unittest-ctnl2'] );
101
-		$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $item );
100
+		$item = $this->object->editAddressItem($item->getId(), ['customer.address.lastname' => 'unittest-ctnl2']);
101
+		$this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $item);
102 102
 
103
-		$item->setLastName( 'test' );
104
-		$this->object->saveAddressItem( $item );
105
-		$this->assertEquals( 'test', $item->getLastName() );
103
+		$item->setLastName('test');
104
+		$this->object->saveAddressItem($item);
105
+		$this->assertEquals('test', $item->getLastName());
106 106
 
107
-		$this->object->deleteAddressItem( $item->getId() );
107
+		$this->object->deleteAddressItem($item->getId());
108 108
 	}
109 109
 
110 110
 
111 111
 	public function testCreateAddressItem()
112 112
 	{
113 113
 		$result = $this->object->createAddressItem();
114
-		$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $result );
114
+		$this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $result);
115 115
 	}
116 116
 
117 117
 
118 118
 	public function testGetAddressItem()
119 119
 	{
120
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer/address' );
120
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer/address');
121 121
 		$search = $manager->createSearch();
122
-		$search->setSlice( 0, 1 );
123
-		$result = $manager->searchItems( $search );
122
+		$search->setSlice(0, 1);
123
+		$result = $manager->searchItems($search);
124 124
 
125
-		if( ( $item = reset( $result ) ) === false ) {
126
-			throw new \RuntimeException( 'No customer address available' );
125
+		if (($item = reset($result)) === false) {
126
+			throw new \RuntimeException('No customer address available');
127 127
 		}
128 128
 
129
-		$this->context->setUserId( $item->getParentId() );
130
-		$result = $this->object->getAddressItem( $item->getId() );
131
-		$this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $result );
129
+		$this->context->setUserId($item->getParentId());
130
+		$result = $this->object->getAddressItem($item->getId());
131
+		$this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $result);
132 132
 	}
133 133
 
134 134
 
135 135
 	public function testAddEditDeleteListItem()
136 136
 	{
137
-		$customer = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' );
138
-		$this->context->setUserId( $customer->getId() );
137
+		$customer = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001');
138
+		$this->context->setUserId($customer->getId());
139 139
 
140 140
 		$values = [
141 141
 			'customer.lists.type' => 'favorite',
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
 			'customer.lists.refid' => '-1'
144 144
 		];
145 145
 
146
-		$item = $this->object->addListItem( $values );
147
-		$this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item );
146
+		$item = $this->object->addListItem($values);
147
+		$this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item);
148 148
 
149 149
 		$values = [
150 150
 			'customer.lists.type' => 'favorite',
@@ -152,46 +152,46 @@  discard block
 block discarded – undo
152 152
 			'customer.lists.refid' => '-2'
153 153
 		];
154 154
 
155
-		$item = $this->object->editListItem( $item->getId(), $values );
156
-		$this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item );
155
+		$item = $this->object->editListItem($item->getId(), $values);
156
+		$this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item);
157 157
 
158
-		$this->object->deleteListItem( $item->getId() );
158
+		$this->object->deleteListItem($item->getId());
159 159
 
160
-		$this->setExpectedException( '\Aimeos\MShop\Exception' );
161
-		$this->object->getListItem( $item->getId() );
160
+		$this->setExpectedException('\Aimeos\MShop\Exception');
161
+		$this->object->getListItem($item->getId());
162 162
 	}
163 163
 
164 164
 
165 165
 	public function testGetListItem()
166 166
 	{
167
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer/lists' );
167
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer/lists');
168 168
 		$search = $manager->createSearch();
169
-		$search->setSlice( 0, 1 );
170
-		$result = $manager->searchItems( $search );
169
+		$search->setSlice(0, 1);
170
+		$result = $manager->searchItems($search);
171 171
 
172
-		if( ( $item = reset( $result ) ) === false ) {
173
-			throw new \RuntimeException( 'No customer lists item available' );
172
+		if (($item = reset($result)) === false) {
173
+			throw new \RuntimeException('No customer lists item available');
174 174
 		}
175 175
 
176
-		$this->context->setUserId( $item->getParentId() );
177
-		$result = $this->object->getListItem( $item->getId() );
178
-		$this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $result );
176
+		$this->context->setUserId($item->getParentId());
177
+		$result = $this->object->getListItem($item->getId());
178
+		$this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $result);
179 179
 	}
180 180
 
181 181
 
182 182
 	public function testSearchListItem()
183 183
 	{
184
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' );
185
-		$customer = $manager->findItem( 'UTC001' );
186
-		$this->context->setUserId( $customer->getId() );
184
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer');
185
+		$customer = $manager->findItem('UTC001');
186
+		$this->context->setUserId($customer->getId());
187 187
 
188 188
 		$filter = $this->object->createListsFilter();
189
-		$result = $this->object->searchListItems( $filter );
189
+		$result = $this->object->searchListItems($filter);
190 190
 
191
-		foreach( $result as $item )
191
+		foreach ($result as $item)
192 192
 		{
193
-			$this->assertEquals( $customer->getId(), $item->getParentId() );
194
-			$this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item );
193
+			$this->assertEquals($customer->getId(), $item->getParentId());
194
+			$this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item);
195 195
 		}
196 196
 	}
197 197
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Customer/Standard.php 2 patches
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -28,23 +28,23 @@  discard block
 block discarded – undo
28 28
 	 * @return \Aimeos\MShop\Customer\Item\Iface Customer item
29 29
 	 * @since 2017.04
30 30
 	 */
31
-	public function addItem( array $values )
31
+	public function addItem(array $values)
32 32
 	{
33 33
 		$context = $this->getContext();
34 34
 		$config = $context->getConfig();
35 35
 
36
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' );
37
-		$values = $this->addItemDefaults( $values );
36
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'customer');
37
+		$values = $this->addItemDefaults($values);
38 38
 
39 39
 		try
40 40
 		{
41
-			$item = $manager->findItem( $values['customer.code'] );
41
+			$item = $manager->findItem($values['customer.code']);
42 42
 		}
43
-		catch( \Aimeos\MShop\Exception $e )
43
+		catch (\Aimeos\MShop\Exception $e)
44 44
 		{
45 45
 			$item = $manager->createItem();
46
-			$item->fromArray( $values );
47
-			$item->setId( null );
46
+			$item->fromArray($values);
47
+			$item->setId(null);
48 48
 
49 49
 			/** controller/frontend/customer/groupids
50 50
 			 * List of groups new customers should be assigned to
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
 			 * @category User
59 59
 			 * @category Developer
60 60
 			 */
61
-			$gids = $config->get( 'client/html/checkout/standard/order/account/standard/groupids', [] ); // @deprecated
62
-			$item->setGroups( (array) $config->get( 'controller/frontend/customer/groupids', $gids ) );
61
+			$gids = $config->get('client/html/checkout/standard/order/account/standard/groupids', []); // @deprecated
62
+			$item->setGroups((array) $config->get('controller/frontend/customer/groupids', $gids));
63 63
 
64
-			$item = $manager->saveItem( $item );
64
+			$item = $manager->saveItem($item);
65 65
 
66 66
 			$msg = $item->toArray();
67 67
 			$msg['customer.password'] = $values['customer.password'];
68
-			$context->getMessageQueue( 'mq-email', 'customer/email/account' )->add( json_encode( $msg ) );
68
+			$context->getMessageQueue('mq-email', 'customer/email/account')->add(json_encode($msg));
69 69
 		}
70 70
 
71 71
 		return $item;
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return \Aimeos\MShop\Customer\Item\Iface Customer item
79 79
 	 */
80
-	public function createItem( array $values = [] )
80
+	public function createItem(array $values = [])
81 81
 	{
82
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' );
82
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer');
83 83
 
84 84
 		$item = $manager->createItem();
85
-		$item->fromArray( $values );
86
-		$item->setId( null );
87
-		$item->setStatus( 1 );
85
+		$item->fromArray($values);
86
+		$item->setId(null);
87
+		$item->setStatus(1);
88 88
 
89 89
 		return $item;
90 90
 	}
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
 	 * @param string $id Unique customer ID
97 97
 	 * @since 2017.04
98 98
 	 */
99
-	public function deleteItem( $id )
99
+	public function deleteItem($id)
100 100
 	{
101
-		$this->checkUser( $id );
101
+		$this->checkUser($id);
102 102
 
103
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' );
104
-		$manager->deleteItem( $id );
103
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer');
104
+		$manager->deleteItem($id);
105 105
 	}
106 106
 
107 107
 
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 	 * @return \Aimeos\MShop\Customer\Item\Iface Customer item
114 114
 	 * @since 2017.04
115 115
 	 */
116
-	public function editItem( $id, array $values )
116
+	public function editItem($id, array $values)
117 117
 	{
118
-		$this->checkUser( $id );
118
+		$this->checkUser($id);
119 119
 
120
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' );
121
-		$item = $manager->getItem( $id, [], true );
120
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer');
121
+		$item = $manager->getItem($id, [], true);
122 122
 
123
-		unset( $values['customer.id'] );
124
-		$item->fromArray( $values );
123
+		unset($values['customer.id']);
124
+		$item->fromArray($values);
125 125
 
126
-		return $manager->saveItem( $item );
126
+		return $manager->saveItem($item);
127 127
 	}
128 128
 
129 129
 
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
 	 * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items
136 136
 	 * @since 2017.04
137 137
 	 */
138
-	public function getItem( $id = null, array $domains = [] )
138
+	public function getItem($id = null, array $domains = [])
139 139
 	{
140
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' );
140
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer');
141 141
 
142
-		if( $id == null ) {
143
-			return $manager->getItem( $this->getContext()->getUserId(), $domains, true );
142
+		if ($id == null) {
143
+			return $manager->getItem($this->getContext()->getUserId(), $domains, true);
144 144
 		}
145 145
 
146
-		$this->checkUser( $id );
146
+		$this->checkUser($id);
147 147
 
148
-		return $manager->getItem( $id, $domains, true );
148
+		return $manager->getItem($id, $domains, true);
149 149
 	}
150 150
 
151 151
 
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 	 * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items
160 160
 	 * @since 2017.04
161 161
 	 */
162
-	public function findItem( $code, array $domains = [] )
162
+	public function findItem($code, array $domains = [])
163 163
 	{
164
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' )->findItem( $code, $domains );
164
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer')->findItem($code, $domains);
165 165
 	}
166 166
 
167 167
 
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 	 * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item
172 172
 	 * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item including the generated ID
173 173
 	 */
174
-	public function saveItem( \Aimeos\MShop\Customer\Item\Iface $item )
174
+	public function saveItem(\Aimeos\MShop\Customer\Item\Iface $item)
175 175
 	{
176
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' )->saveItem( $item );
176
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer')->saveItem($item);
177 177
 	}
178 178
 
179 179
 
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 	 * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item
185 185
 	 * @since 2017.04
186 186
 	 */
187
-	public function addAddressItem( array $values )
187
+	public function addAddressItem(array $values)
188 188
 	{
189 189
 		$context = $this->getContext();
190
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/address' );
190
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'customer/address');
191 191
 
192 192
 		$item = $manager->createItem();
193
-		$item->fromArray( $values );
194
-		$item->setId( null );
195
-		$item->setParentId( $context->getUserId() );
193
+		$item->fromArray($values);
194
+		$item->setId(null);
195
+		$item->setParentId($context->getUserId());
196 196
 
197
-		return $manager->saveItem( $item );
197
+		return $manager->saveItem($item);
198 198
 	}
199 199
 
200 200
 
@@ -203,16 +203,16 @@  discard block
 block discarded – undo
203 203
 	 *
204 204
 	 * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item
205 205
 	 */
206
-	public function createAddressItem( array $values = [] )
206
+	public function createAddressItem(array $values = [])
207 207
 	{
208 208
 		$context = $this->getContext();
209
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/address' );
209
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'customer/address');
210 210
 
211 211
 		$item = $manager->createItem();
212
-		$item->fromArray( $values );
213
-		$item->setId( null );
212
+		$item->fromArray($values);
213
+		$item->setId(null);
214 214
 
215
-		$item->setParentId( $context->getUserId() );
215
+		$item->setParentId($context->getUserId());
216 216
 
217 217
 		return $item;
218 218
 	}
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
 	 * @param string $id Unique customer address ID
225 225
 	 * @since 2017.04
226 226
 	 */
227
-	public function deleteAddressItem( $id )
227
+	public function deleteAddressItem($id)
228 228
 	{
229
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' );
229
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address');
230 230
 
231
-		$this->checkUser( $manager->getItem( $id, [], true )->getParentId() );
231
+		$this->checkUser($manager->getItem($id, [], true)->getParentId());
232 232
 
233
-		$manager->deleteItem( $id );
233
+		$manager->deleteItem($id);
234 234
 	}
235 235
 
236 236
 
@@ -242,17 +242,17 @@  discard block
 block discarded – undo
242 242
 	 * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item
243 243
 	 * @since 2017.04
244 244
 	 */
245
-	public function editAddressItem( $id, array $values )
245
+	public function editAddressItem($id, array $values)
246 246
 	{
247
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' );
247
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address');
248 248
 
249
-		$item = $manager->getItem( $id, [], true );
250
-		$this->checkUser( $item->getParentId() );
249
+		$item = $manager->getItem($id, [], true);
250
+		$this->checkUser($item->getParentId());
251 251
 
252
-		unset( $values['customer.address.id'] );
253
-		$item->fromArray( $values );
252
+		unset($values['customer.address.id']);
253
+		$item->fromArray($values);
254 254
 
255
-		return $manager->saveItem( $item );
255
+		return $manager->saveItem($item);
256 256
 	}
257 257
 
258 258
 
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
 	 * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item
264 264
 	 * @since 2017.04
265 265
 	 */
266
-	public function getAddressItem( $id )
266
+	public function getAddressItem($id)
267 267
 	{
268
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' );
268
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address');
269 269
 
270
-		$item = $manager->getItem( $id );
271
-		$this->checkUser( $item->getParentId() );
270
+		$item = $manager->getItem($id);
271
+		$this->checkUser($item->getParentId());
272 272
 
273 273
 		return $item;
274 274
 	}
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
 	 * @param \Aimeos\MShop\Customer\Item\Address\Iface $item Customer address item
281 281
 	 * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item including the generated ID
282 282
 	 */
283
-	public function saveAddressItem( \Aimeos\MShop\Customer\Item\Address\Iface $item )
283
+	public function saveAddressItem(\Aimeos\MShop\Customer\Item\Address\Iface $item)
284 284
 	{
285
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' )->saveItem( $item );
285
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address')->saveItem($item);
286 286
 	}
287 287
 
288 288
 
@@ -293,32 +293,32 @@  discard block
 block discarded – undo
293 293
 	 * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item
294 294
 	 * @since 2017.06
295 295
 	 */
296
-	public function addListItem( array $values )
296
+	public function addListItem(array $values)
297 297
 	{
298 298
 		$context = $this->getContext();
299
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' );
299
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists');
300 300
 
301
-		if( !isset( $values['customer.lists.typeid'] ) )
301
+		if (!isset($values['customer.lists.typeid']))
302 302
 		{
303
-			if( !isset( $values['customer.lists.type'] ) ) {
304
-				throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists type code' ) );
303
+			if (!isset($values['customer.lists.type'])) {
304
+				throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists type code'));
305 305
 			}
306 306
 
307
-			if( !isset( $values['customer.lists.domain'] ) ) {
308
-				throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists domain' ) );
307
+			if (!isset($values['customer.lists.domain'])) {
308
+				throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists domain'));
309 309
 			}
310 310
 
311
-			$typeManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists/type' );
312
-			$typeItem = $typeManager->findItem( $values['customer.lists.type'], [], $values['customer.lists.domain'] );
311
+			$typeManager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists/type');
312
+			$typeItem = $typeManager->findItem($values['customer.lists.type'], [], $values['customer.lists.domain']);
313 313
 			$values['customer.lists.typeid'] = $typeItem->getId();
314 314
 		}
315 315
 
316 316
 		$item = $manager->createItem();
317
-		$item->fromArray( $values );
318
-		$item->setId( null );
319
-		$item->setParentId( $context->getUserId() );
317
+		$item->fromArray($values);
318
+		$item->setId(null);
319
+		$item->setParentId($context->getUserId());
320 320
 
321
-		return $manager->saveItem( $item );
321
+		return $manager->saveItem($item);
322 322
 	}
323 323
 
324 324
 
@@ -331,10 +331,10 @@  discard block
 block discarded – undo
331 331
 	public function createListsFilter()
332 332
 	{
333 333
 		$context = $this->getContext();
334
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' );
334
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists');
335 335
 
336 336
 		$filter = $manager->createSearch();
337
-		$filter->setConditions( $filter->compare( '==', 'customer.lists.parentid', $context->getUserId() ) );
337
+		$filter->setConditions($filter->compare('==', 'customer.lists.parentid', $context->getUserId()));
338 338
 
339 339
 		return $filter;
340 340
 	}
@@ -346,13 +346,13 @@  discard block
 block discarded – undo
346 346
 	 * @param string $id Unique customer address ID
347 347
 	 * @since 2017.06
348 348
 	 */
349
-	public function deleteListItem( $id )
349
+	public function deleteListItem($id)
350 350
 	{
351
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' );
351
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists');
352 352
 
353
-		$this->checkUser( $manager->getItem( $id )->getParentId() );
353
+		$this->checkUser($manager->getItem($id)->getParentId());
354 354
 
355
-		$manager->deleteItem( $id );
355
+		$manager->deleteItem($id);
356 356
 	}
357 357
 
358 358
 
@@ -364,33 +364,33 @@  discard block
 block discarded – undo
364 364
 	 * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item
365 365
 	 * @since 2017.06
366 366
 	 */
367
-	public function editListItem( $id, array $values )
367
+	public function editListItem($id, array $values)
368 368
 	{
369 369
 		$context = $this->getContext();
370
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' );
370
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists');
371 371
 
372
-		$item = $manager->getItem( $id, [], true );
373
-		$this->checkUser( $item->getParentId() );
372
+		$item = $manager->getItem($id, [], true);
373
+		$this->checkUser($item->getParentId());
374 374
 
375
-		if( !isset( $values['customer.lists.typeid'] ) )
375
+		if (!isset($values['customer.lists.typeid']))
376 376
 		{
377
-			if( !isset( $values['customer.lists.type'] ) ) {
378
-				throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists type code' ) );
377
+			if (!isset($values['customer.lists.type'])) {
378
+				throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists type code'));
379 379
 			}
380 380
 
381
-			if( !isset( $values['customer.lists.domain'] ) ) {
382
-				throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists domain' ) );
381
+			if (!isset($values['customer.lists.domain'])) {
382
+				throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists domain'));
383 383
 			}
384 384
 
385
-			$typeManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists/type' );
386
-			$typeItem = $typeManager->findItem( $values['customer.lists.type'], [], $values['customer.lists.domain'] );
385
+			$typeManager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists/type');
386
+			$typeItem = $typeManager->findItem($values['customer.lists.type'], [], $values['customer.lists.domain']);
387 387
 			$values['customer.lists.typeid'] = $typeItem->getId();
388 388
 		}
389 389
 
390
-		unset( $values['customer.lists.id'] );
391
-		$item->fromArray( $values );
390
+		unset($values['customer.lists.id']);
391
+		$item->fromArray($values);
392 392
 
393
-		return $manager->saveItem( $item );
393
+		return $manager->saveItem($item);
394 394
 	}
395 395
 
396 396
 
@@ -401,12 +401,12 @@  discard block
 block discarded – undo
401 401
 	 * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item
402 402
 	 * @since 2017.06
403 403
 	 */
404
-	public function getListItem( $id )
404
+	public function getListItem($id)
405 405
 	{
406
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' );
407
-		$item = $manager->getItem( $id );
406
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists');
407
+		$item = $manager->getItem($id);
408 408
 
409
-		$this->checkUser( $item->getParentId() );
409
+		$this->checkUser($item->getParentId());
410 410
 
411 411
 		return $item;
412 412
 	}
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 	 * @return \Aimeos\MShop\Common\Item\Lists\Iface[] Customer list items
421 421
 	 * @since 2017.06
422 422
 	 */
423
-	public function searchListItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null )
423
+	public function searchListItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null)
424 424
 	{
425
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' );
425
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists');
426 426
 
427
-		return $manager->searchItems( $filter, [], $total );
427
+		return $manager->searchItems($filter, [], $total);
428 428
 	}
429 429
 
430 430
 
@@ -434,37 +434,37 @@  discard block
 block discarded – undo
434 434
 	 * @param string[] $values Associative list of customer keys (e.g. "customer.label") and their values
435 435
 	 * @return string[] Associative list of customer key/value pairs with default values set
436 436
 	 */
437
-	protected function addItemDefaults( array $values )
437
+	protected function addItemDefaults(array $values)
438 438
 	{
439
-		if( !isset( $values['customer.label'] ) || $values['customer.label'] == '' )
439
+		if (!isset($values['customer.label']) || $values['customer.label'] == '')
440 440
 		{
441 441
 			$label = '';
442 442
 
443
-			if( isset( $values['customer.lastname'] ) ) {
443
+			if (isset($values['customer.lastname'])) {
444 444
 				$label = $values['customer.lastname'];
445 445
 			}
446 446
 
447
-			if( isset( $values['customer.firstname'] ) && $values['customer.firstname'] != '' ) {
447
+			if (isset($values['customer.firstname']) && $values['customer.firstname'] != '') {
448 448
 				$label = $values['customer.firstname'] . ' ' . $label;
449 449
 			}
450 450
 
451
-			if( isset( $values['customer.company'] ) && $values['customer.company'] != '' ) {
451
+			if (isset($values['customer.company']) && $values['customer.company'] != '') {
452 452
 				$label .= ' (' . $values['customer.company'] . ')';
453 453
 			}
454 454
 
455 455
 			$values['customer.label'] = $label;
456 456
 		}
457 457
 
458
-		if( !isset( $values['customer.code'] ) ) {
458
+		if (!isset($values['customer.code'])) {
459 459
 			$values['customer.code'] = $values['customer.email'];
460 460
 		}
461 461
 
462
-		if( !isset( $values['customer.status'] ) ) {
462
+		if (!isset($values['customer.status'])) {
463 463
 			$values['customer.status'] = 1;
464 464
 		}
465 465
 
466
-		if( !isset( $values['customer.password'] ) ) {
467
-			$values['customer.password'] = substr( md5( microtime( true ) . getmypid() . rand() ), -8 );
466
+		if (!isset($values['customer.password'])) {
467
+			$values['customer.password'] = substr(md5(microtime(true) . getmypid() . rand()), -8);
468 468
 		}
469 469
 
470 470
 		return $values;
@@ -477,12 +477,12 @@  discard block
 block discarded – undo
477 477
 	 * @param string $id Unique customer ID
478 478
 	 * @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed
479 479
 	 */
480
-	protected function checkUser( $id )
480
+	protected function checkUser($id)
481 481
 	{
482
-		if( $id != $this->getContext()->getUserId() )
482
+		if ($id != $this->getContext()->getUserId())
483 483
 		{
484
-			$msg = sprintf( 'Not allowed to access customer data for ID "%1$s"', $id );
485
-			throw new \Aimeos\Controller\Frontend\Customer\Exception( $msg );
484
+			$msg = sprintf('Not allowed to access customer data for ID "%1$s"', $id);
485
+			throw new \Aimeos\Controller\Frontend\Customer\Exception($msg);
486 486
 		}
487 487
 	}
488 488
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,8 +39,7 @@
 block discarded – undo
39 39
 		try
40 40
 		{
41 41
 			$item = $manager->findItem( $values['customer.code'] );
42
-		}
43
-		catch( \Aimeos\MShop\Exception $e )
42
+		} catch( \Aimeos\MShop\Exception $e )
44 43
 		{
45 44
 			$item = $manager->createItem();
46 45
 			$item->fromArray( $values );
Please login to merge, or discard this patch.