Completed
Push — master ( 9bf8ab...afe8d8 )
by Aimeos
07:50
created
controller/frontend/src/Controller/Frontend/Basket/Standard.php 1 patch
Spacing   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Object storing the required instances for manaing databases
34 34
 	 *  connections, logger, session, etc.
35 35
 	 */
36
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context )
36
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context)
37 37
 	{
38
-		parent::__construct( $context );
38
+		parent::__construct($context);
39 39
 
40
-		$this->domainManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' );
40
+		$this->domainManager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
41 41
 	}
42 42
 
43 43
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	public function clear()
50 50
 	{
51 51
 		$this->baskets[$this->type] = $this->domainManager->createItem();
52
-		$this->domainManager->setSession( $this->baskets[$this->type], $this->type );
52
+		$this->domainManager->setSession($this->baskets[$this->type], $this->type);
53 53
 
54 54
 		return $this;
55 55
 	}
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function get()
64 64
 	{
65
-		if( !isset( $this->baskets[$this->type] ) )
65
+		if (!isset($this->baskets[$this->type]))
66 66
 		{
67
-			$this->baskets[$this->type] = $this->domainManager->getSession( $this->type );
68
-			$this->checkLocale( $this->baskets[$this->type]->getLocale(), $this->type );
67
+			$this->baskets[$this->type] = $this->domainManager->getSession($this->type);
68
+			$this->checkLocale($this->baskets[$this->type]->getLocale(), $this->type);
69 69
 		}
70 70
 
71 71
 		return $this->baskets[$this->type];
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function save()
81 81
 	{
82
-		if( isset( $this->baskets[$this->type] ) && $this->baskets[$this->type]->isModified() ) {
83
-			$this->domainManager->setSession( $this->baskets[$this->type], $this->type );
82
+		if (isset($this->baskets[$this->type]) && $this->baskets[$this->type]->isModified()) {
83
+			$this->domainManager->setSession($this->baskets[$this->type], $this->type);
84 84
 		}
85 85
 
86 86
 		return $this;
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @param string $type Basket type
94 94
 	 * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object
95 95
 	 */
96
-	public function setType( $type )
96
+	public function setType($type)
97 97
 	{
98 98
 		$this->type = $type;
99 99
 		return $this;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		 * @category Developer
128 128
 		 * @see controller/frontend/basket/limit-seconds
129 129
 		 */
130
-		$count = $config->get( 'controller/frontend/basket/limit-count', 5 );
130
+		$count = $config->get('controller/frontend/basket/limit-count', 5);
131 131
 
132 132
 		/** controller/frontend/basket/limit-seconds
133 133
 		 * Order limitation time frame in seconds
@@ -145,30 +145,30 @@  discard block
 block discarded – undo
145 145
 		 * @category Developer
146 146
 		 * @see controller/frontend/basket/limit-count
147 147
 		 */
148
-		$seconds = $config->get( 'controller/frontend/basket/limit-seconds', 300 );
148
+		$seconds = $config->get('controller/frontend/basket/limit-seconds', 300);
149 149
 
150 150
 		$search = $this->domainManager->createSearch();
151 151
 		$expr = [
152
-			$search->compare( '==', 'order.base.editor', $context->getEditor() ),
153
-			$search->compare( '>=', 'order.base.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ),
152
+			$search->compare('==', 'order.base.editor', $context->getEditor()),
153
+			$search->compare('>=', 'order.base.ctime', date('Y-m-d H:i:s', time() - $seconds)),
154 154
 		];
155
-		$search->setConditions( $search->combine( '&&', $expr ) );
156
-		$search->setSlice( 0, 0 );
155
+		$search->setConditions($search->combine('&&', $expr));
156
+		$search->setSlice(0, 0);
157 157
 
158
-		$this->domainManager->searchItems( $search, [], $total );
158
+		$this->domainManager->searchItems($search, [], $total);
159 159
 
160
-		if( $total > $count )
160
+		if ($total > $count)
161 161
 		{
162
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Temporary order limit reached' );
163
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
162
+			$msg = $context->getI18n()->dt('controller/frontend', 'Temporary order limit reached');
163
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
164 164
 		}
165 165
 
166 166
 
167 167
 		$basket = $this->get()->finish();
168
-		$basket->setCustomerId( (string) $context->getUserId() );
168
+		$basket->setCustomerId((string) $context->getUserId());
169 169
 
170 170
 		$this->domainManager->begin();
171
-		$this->domainManager->store( $basket );
171
+		$this->domainManager->store($basket);
172 172
 		$this->domainManager->commit();
173 173
 
174 174
 		return $basket;
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	 * @param boolean $default True to add default criteria (user logged in), false if not
184 184
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts
185 185
 	 */
186
-	public function load( $id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true )
186
+	public function load($id, $parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL, $default = true)
187 187
 	{
188
-		return $this->domainManager->load( $id, $parts, false, $default );
188
+		return $this->domainManager->load($id, $parts, false, $default);
189 189
 	}
190 190
 
191 191
 
@@ -204,33 +204,33 @@  discard block
 block discarded – undo
204 204
 	 * @param string $stocktype Unique code of the stock type to deliver the products from
205 205
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available
206 206
 	 */
207
-	public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [],
208
-		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] )
207
+	public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [],
208
+		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [])
209 209
 	{
210 210
 		$attributeMap = [
211
-			'custom' => array_keys( $customAttributeValues ),
212
-			'config' => array_keys( $configAttributeIds ),
211
+			'custom' => array_keys($customAttributeValues),
212
+			'config' => array_keys($configAttributeIds),
213 213
 			'hidden' => $hiddenAttributeIds,
214 214
 		];
215
-		$this->checkListRef( $prodid, 'attribute', $attributeMap );
215
+		$this->checkListRef($prodid, 'attribute', $attributeMap);
216 216
 
217 217
 
218 218
 		$context = $this->getContext();
219
-		$productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
220
-		$productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true );
221
-		$prices = $productItem->getRefItems( 'price', 'default', 'default' );
219
+		$productManager = \Aimeos\MShop\Factory::createManager($context, 'product');
220
+		$productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true);
221
+		$prices = $productItem->getRefItems('price', 'default', 'default');
222 222
 
223
-		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem();
224
-		$orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype );
223
+		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem();
224
+		$orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype);
225 225
 
226
-		$attr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues );
227
-		$attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', array_keys( $configAttributeIds ), [], $configAttributeIds ) );
228
-		$attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) );
226
+		$attr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues);
227
+		$attr = array_merge($attr, $this->getOrderProductAttributes('config', array_keys($configAttributeIds), [], $configAttributeIds));
228
+		$attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds));
229 229
 
230
-		$orderBaseProductItem->setAttributes( $attr );
231
-		$orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) );
230
+		$orderBaseProductItem->setAttributes($attr);
231
+		$orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity));
232 232
 
233
-		$this->get()->addProduct( $orderBaseProductItem );
233
+		$this->get()->addProduct($orderBaseProductItem);
234 234
 		$this->save();
235 235
 	}
236 236
 
@@ -240,17 +240,17 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @param integer $position Position number (key) of the order product item
242 242
 	 */
243
-	public function deleteProduct( $position )
243
+	public function deleteProduct($position)
244 244
 	{
245
-		$product = $this->get()->getProduct( $position );
245
+		$product = $this->get()->getProduct($position);
246 246
 
247
-		if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE )
247
+		if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE)
248 248
 		{
249
-			$msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be deleted manually' );
250
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) );
249
+			$msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Basket item at position "%1$d" cannot be deleted manually');
250
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $position));
251 251
 		}
252 252
 
253
-		$this->get()->deleteProduct( $position );
253
+		$this->get()->deleteProduct($position);
254 254
 		$this->save();
255 255
 	}
256 256
 
@@ -262,32 +262,32 @@  discard block
 block discarded – undo
262 262
 	 * @param integer $quantity New quantiy of the product item
263 263
 	 * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED
264 264
 	 */
265
-	public function editProduct( $position, $quantity, array $configAttributeCodes = [] )
265
+	public function editProduct($position, $quantity, array $configAttributeCodes = [])
266 266
 	{
267
-		$product = $this->get()->getProduct( $position );
267
+		$product = $this->get()->getProduct($position);
268 268
 
269
-		if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE )
269
+		if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE)
270 270
 		{
271
-			$msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be changed' );
272
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) );
271
+			$msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Basket item at position "%1$d" cannot be changed');
272
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $position));
273 273
 		}
274 274
 
275
-		$product->setQuantity( $quantity );
275
+		$product->setQuantity($quantity);
276 276
 
277 277
 		$attributes = $product->getAttributes();
278
-		foreach( $attributes as $key => $attribute )
278
+		foreach ($attributes as $key => $attribute)
279 279
 		{
280
-			if( in_array( $attribute->getCode(), $configAttributeCodes ) ) {
281
-				unset( $attributes[$key] );
280
+			if (in_array($attribute->getCode(), $configAttributeCodes)) {
281
+				unset($attributes[$key]);
282 282
 			}
283 283
 		}
284
-		$product->setAttributes( $attributes );
284
+		$product->setAttributes($attributes);
285 285
 
286
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
287
-		$productItem = $manager->findItem( $product->getProductCode(), array( 'price', 'text' ), true );
288
-		$product->setPrice( $this->calcPrice( $product, $productItem->getRefItems( 'price', 'default' ), $quantity ) );
286
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
287
+		$productItem = $manager->findItem($product->getProductCode(), array('price', 'text'), true);
288
+		$product->setPrice($this->calcPrice($product, $productItem->getRefItems('price', 'default'), $quantity));
289 289
 
290
-		$this->get()->editProduct( $product, $position );
290
+		$this->get()->editProduct($product, $position);
291 291
 
292 292
 		$this->save();
293 293
 	}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @param string $code Coupon code entered by the user
300 300
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed
301 301
 	 */
302
-	public function addCoupon( $code )
302
+	public function addCoupon($code)
303 303
 	{
304 304
 		$context = $this->getContext();
305 305
 
@@ -319,39 +319,39 @@  discard block
 block discarded – undo
319 319
 		 * @category User
320 320
 		 * @category Developer
321 321
 		 */
322
-		$allowed = $context->getConfig()->get( 'controller/frontend/basket/standard/coupon/allowed', 1 );
322
+		$allowed = $context->getConfig()->get('controller/frontend/basket/standard/coupon/allowed', 1);
323 323
 
324
-		if( $allowed <= count( $this->get()->getCoupons() ) )
324
+		if ($allowed <= count($this->get()->getCoupons()))
325 325
 		{
326
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Number of coupon codes exceeds the limit' );
327
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
326
+			$msg = $context->getI18n()->dt('controller/frontend', 'Number of coupon codes exceeds the limit');
327
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
328 328
 		}
329 329
 
330 330
 
331
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'coupon' );
331
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'coupon');
332 332
 
333 333
 		$search = $manager->createSearch();
334
-		$search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) );
335
-		$search->setSlice( 0, 1 );
334
+		$search->setConditions($search->compare('==', 'coupon.code.code', $code));
335
+		$search->setSlice(0, 1);
336 336
 
337
-		$result = $manager->searchItems( $search );
337
+		$result = $manager->searchItems($search);
338 338
 
339
-		if( ( $item = reset( $result ) ) === false )
339
+		if (($item = reset($result)) === false)
340 340
 		{
341
-			$msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Coupon code "%1$s" is invalid or not available any more' ), $code );
342
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
341
+			$msg = sprintf($context->getI18n()->dt('controller/frontend', 'Coupon code "%1$s" is invalid or not available any more'), $code);
342
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
343 343
 		}
344 344
 
345 345
 
346
-		$provider = $manager->getProvider( $item, $code );
346
+		$provider = $manager->getProvider($item, $code);
347 347
 
348
-		if( $provider->isAvailable( $this->get() ) !== true )
348
+		if ($provider->isAvailable($this->get()) !== true)
349 349
 		{
350
-			$msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Requirements for coupon code "%1$s" aren\'t met' ), $code );
351
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
350
+			$msg = sprintf($context->getI18n()->dt('controller/frontend', 'Requirements for coupon code "%1$s" aren\'t met'), $code);
351
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
352 352
 		}
353 353
 
354
-		$provider->addCoupon( $this->get() );
354
+		$provider->addCoupon($this->get());
355 355
 		$this->save();
356 356
 	}
357 357
 
@@ -362,24 +362,24 @@  discard block
 block discarded – undo
362 362
 	 * @param string $code Coupon code entered by the user
363 363
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid
364 364
 	 */
365
-	public function deleteCoupon( $code )
365
+	public function deleteCoupon($code)
366 366
 	{
367 367
 		$context = $this->getContext();
368
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'coupon' );
368
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'coupon');
369 369
 
370 370
 		$search = $manager->createSearch();
371
-		$search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) );
372
-		$search->setSlice( 0, 1 );
371
+		$search->setConditions($search->compare('==', 'coupon.code.code', $code));
372
+		$search->setSlice(0, 1);
373 373
 
374
-		$result = $manager->searchItems( $search );
374
+		$result = $manager->searchItems($search);
375 375
 
376
-		if( ( $item = reset( $result ) ) === false )
376
+		if (($item = reset($result)) === false)
377 377
 		{
378
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Coupon code "%1$s" is invalid' );
379
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $code ) );
378
+			$msg = $context->getI18n()->dt('controller/frontend', 'Coupon code "%1$s" is invalid');
379
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $code));
380 380
 		}
381 381
 
382
-		$manager->getProvider( $item, $code )->deleteCoupon( $this->get() );
382
+		$manager->getProvider($item, $code)->deleteCoupon($this->get());
383 383
 		$this->save();
384 384
 	}
385 385
 
@@ -392,30 +392,30 @@  discard block
 block discarded – undo
392 392
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of
393 393
 	 * 	if one of the keys is invalid when using an array with key/value pairs
394 394
 	 */
395
-	public function setAddress( $type, $value )
395
+	public function setAddress($type, $value)
396 396
 	{
397 397
 		$context = $this->getContext();
398
-		$address = \Aimeos\MShop\Factory::createManager( $context, 'order/base/address' )->createItem();
399
-		$address->setType( $type );
398
+		$address = \Aimeos\MShop\Factory::createManager($context, 'order/base/address')->createItem();
399
+		$address->setType($type);
400 400
 
401
-		if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface )
401
+		if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface)
402 402
 		{
403
-			$address->copyFrom( $value );
404
-			$this->get()->setAddress( $address, $type );
403
+			$address->copyFrom($value);
404
+			$this->get()->setAddress($address, $type);
405 405
 		}
406
-		else if( is_array( $value ) )
406
+		else if (is_array($value))
407 407
 		{
408
-			$this->setAddressFromArray( $address, $value );
409
-			$this->get()->setAddress( $address, $type );
408
+			$this->setAddressFromArray($address, $value);
409
+			$this->get()->setAddress($address, $type);
410 410
 		}
411
-		else if( $value === null )
411
+		else if ($value === null)
412 412
 		{
413
-			$this->get()->deleteAddress( $type );
413
+			$this->get()->deleteAddress($type);
414 414
 		}
415 415
 		else
416 416
 		{
417
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid value for address type "%1$s"' );
418
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $type ) );
417
+			$msg = $context->getI18n()->dt('controller/frontend', 'Invalid value for address type "%1$s"');
418
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $type));
419 419
 		}
420 420
 
421 421
 		$this->save();
@@ -431,42 +431,42 @@  discard block
 block discarded – undo
431 431
 	 * 	entered by the customer when choosing one of the delivery or payment options
432 432
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached
433 433
 	 */
434
-	public function addService( $type, $id, array $attributes = [] )
434
+	public function addService($type, $id, array $attributes = [])
435 435
 	{
436 436
 		$context = $this->getContext();
437 437
 
438
-		$serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' );
439
-		$serviceItem = $serviceManager->getItem( $id, array( 'media', 'price', 'text' ) );
438
+		$serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service');
439
+		$serviceItem = $serviceManager->getItem($id, array('media', 'price', 'text'));
440 440
 
441
-		$provider = $serviceManager->getProvider( $serviceItem, $serviceItem->getType() );
442
-		$result = $provider->checkConfigFE( $attributes );
443
-		$unknown = array_diff_key( $attributes, $result );
441
+		$provider = $serviceManager->getProvider($serviceItem, $serviceItem->getType());
442
+		$result = $provider->checkConfigFE($attributes);
443
+		$unknown = array_diff_key($attributes, $result);
444 444
 
445
-		if( count( $unknown ) > 0 )
445
+		if (count($unknown) > 0)
446 446
 		{
447
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Unknown attributes "%1$s"' );
448
-			$msg = sprintf( $msg, implode( '","', array_keys( $unknown ) ) );
449
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
447
+			$msg = $context->getI18n()->dt('controller/frontend', 'Unknown attributes "%1$s"');
448
+			$msg = sprintf($msg, implode('","', array_keys($unknown)));
449
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
450 450
 		}
451 451
 
452
-		foreach( $result as $key => $value )
452
+		foreach ($result as $key => $value)
453 453
 		{
454
-			if( $value !== null ) {
455
-				throw new \Aimeos\Controller\Frontend\Basket\Exception( $value );
454
+			if ($value !== null) {
455
+				throw new \Aimeos\Controller\Frontend\Basket\Exception($value);
456 456
 			}
457 457
 		}
458 458
 
459
-		$orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' );
459
+		$orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service');
460 460
 		$orderServiceItem = $orderBaseServiceManager->createItem();
461
-		$orderServiceItem->copyFrom( $serviceItem );
461
+		$orderServiceItem->copyFrom($serviceItem);
462 462
 
463 463
 		// remove service rebate of original price
464
-		$price = $provider->calcPrice( $this->get() )->setRebate( '0.00' );
465
-		$orderServiceItem->setPrice( $price );
464
+		$price = $provider->calcPrice($this->get())->setRebate('0.00');
465
+		$orderServiceItem->setPrice($price);
466 466
 
467
-		$provider->setConfigFE( $orderServiceItem, $attributes );
467
+		$provider->setConfigFE($orderServiceItem, $attributes);
468 468
 
469
-		$this->get()->addService( $orderServiceItem, $type );
469
+		$this->get()->addService($orderServiceItem, $type);
470 470
 		$this->save();
471 471
 	}
472 472
 
@@ -476,9 +476,9 @@  discard block
 block discarded – undo
476 476
 	 *
477 477
 	 * @param string $type Service type code like 'payment' or 'delivery'
478 478
 	 */
479
-	public function deleteService( $type )
479
+	public function deleteService($type)
480 480
 	{
481
-		$this->get()->deleteService( $type );
481
+		$this->get()->deleteService($type);
482 482
 		$this->save();
483 483
 	}
484 484
 
@@ -491,18 +491,18 @@  discard block
 block discarded – undo
491 491
 	 * 	an address item.
492 492
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception
493 493
 	 */
494
-	protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map )
494
+	protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map)
495 495
 	{
496
-		foreach( $map as $key => $value ) {
497
-			$map[$key] = strip_tags( $value ); // prevent XSS
496
+		foreach ($map as $key => $value) {
497
+			$map[$key] = strip_tags($value); // prevent XSS
498 498
 		}
499 499
 
500
-		$errors = $address->fromArray( $map );
500
+		$errors = $address->fromArray($map);
501 501
 
502
-		if( count( $errors ) > 0 )
502
+		if (count($errors) > 0)
503 503
 		{
504
-			$msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Invalid address properties, please check your input' );
505
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors );
504
+			$msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Invalid address properties, please check your input');
505
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors);
506 506
 		}
507 507
 	}
508 508
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Basket/Base.php 1 patch
Spacing   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -31,52 +31,52 @@  discard block
 block discarded – undo
31 31
 	 * @param integer $quantity New product quantity
32 32
 	 * @return \Aimeos\MShop\Price\Item\Iface Price item with calculated price
33 33
 	 */
34
-	protected function calcPrice( \Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity )
34
+	protected function calcPrice(\Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity)
35 35
 	{
36 36
 		$context = $this->getContext();
37 37
 
38
-		if( empty( $prices ) )
38
+		if (empty($prices))
39 39
 		{
40
-			$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
41
-			$prices = $manager->getItem( $product->getProductId(), array( 'price' ) )->getRefItems( 'price', 'default' );
40
+			$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
41
+			$prices = $manager->getItem($product->getProductId(), array('price'))->getRefItems('price', 'default');
42 42
 		}
43 43
 
44 44
 
45
-		$priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' );
46
-		$price = $priceManager->getLowestPrice( $prices, $quantity );
45
+		$priceManager = \Aimeos\MShop\Factory::createManager($context, 'price');
46
+		$price = $priceManager->getLowestPrice($prices, $quantity);
47 47
 
48 48
 		// customers can pay what they would like to pay
49
-		if( ( $attr = $product->getAttributeItem( 'price', 'custom' ) ) !== null )
49
+		if (($attr = $product->getAttributeItem('price', 'custom')) !== null)
50 50
 		{
51 51
 			$amount = $attr->getValue();
52 52
 
53
-			if( preg_match( '/^[0-9]*(\.[0-9]+)?$/', $amount ) !== 1 || ((double) $amount) < 0.01 )
53
+			if (preg_match('/^[0-9]*(\.[0-9]+)?$/', $amount) !== 1 || ((double) $amount) < 0.01)
54 54
 			{
55
-				$msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid price value "%1$s"' );
56
-				throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $amount ) );
55
+				$msg = $context->getI18n()->dt('controller/frontend', 'Invalid price value "%1$s"');
56
+				throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $amount));
57 57
 			}
58 58
 
59
-			$price->setValue( $amount );
59
+			$price->setValue($amount);
60 60
 		}
61 61
 
62 62
 		$orderAttributes = $product->getAttributes();
63
-		$attrItems = $this->getAttributeItems( $orderAttributes );
63
+		$attrItems = $this->getAttributeItems($orderAttributes);
64 64
 
65 65
 		// add prices of (optional) attributes
66
-		foreach( $orderAttributes as $orderAttrItem )
66
+		foreach ($orderAttributes as $orderAttrItem)
67 67
 		{
68 68
 			$attrId = $orderAttrItem->getAttributeId();
69 69
 
70
-			if( isset( $attrItems[$attrId] )
71
-				&& ( $prices = $attrItems[$attrId]->getRefItems( 'price', 'default' ) ) !== []
70
+			if (isset($attrItems[$attrId])
71
+				&& ($prices = $attrItems[$attrId]->getRefItems('price', 'default')) !== []
72 72
 			) {
73
-				$attrPrice = $priceManager->getLowestPrice( $prices, $orderAttrItem->getQuantity() );
74
-				$price->addItem( $attrPrice, $orderAttrItem->getQuantity() );
73
+				$attrPrice = $priceManager->getLowestPrice($prices, $orderAttrItem->getQuantity());
74
+				$price->addItem($attrPrice, $orderAttrItem->getQuantity());
75 75
 			}
76 76
 		}
77 77
 
78 78
 		// remove product rebate of original price in favor to rebates granted for the order
79
-		$price->setRebate( '0.00' );
79
+		$price->setRebate('0.00');
80 80
 
81 81
 		return $price;
82 82
 	}
@@ -90,43 +90,43 @@  discard block
 block discarded – undo
90 90
 	 * @param array $refMap Associative list of list type codes as keys and lists of reference IDs as values
91 91
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated
92 92
 	 */
93
-	protected function checkListRef( $prodId, $domain, array $refMap )
93
+	protected function checkListRef($prodId, $domain, array $refMap)
94 94
 	{
95
-		if( empty( $refMap ) ) {
95
+		if (empty($refMap)) {
96 96
 			return;
97 97
 		}
98 98
 
99 99
 		$context = $this->getContext();
100
-		$productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
101
-		$search = $productManager->createSearch( true );
100
+		$productManager = \Aimeos\MShop\Factory::createManager($context, 'product');
101
+		$search = $productManager->createSearch(true);
102 102
 
103 103
 		$expr = array(
104
-			$search->compare( '==', 'product.id', $prodId ),
104
+			$search->compare('==', 'product.id', $prodId),
105 105
 			$search->getConditions(),
106 106
 		);
107 107
 
108
-		foreach( $refMap as $listType => $refIds )
108
+		foreach ($refMap as $listType => $refIds)
109 109
 		{
110
-			if( empty( $refIds ) ) {
110
+			if (empty($refIds)) {
111 111
 				continue;
112 112
 			}
113 113
 
114
-			foreach( $refIds as $key => $refId ) {
114
+			foreach ($refIds as $key => $refId) {
115 115
 				$refIds[$key] = (string) $refId;
116 116
 			}
117 117
 
118
-			$param = array( $domain, $this->getProductListTypeItem( $domain, $listType )->getId(), $refIds );
119
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
118
+			$param = array($domain, $this->getProductListTypeItem($domain, $listType)->getId(), $refIds);
119
+			$cmpfunc = $search->createFunction('product.contains', $param);
120 120
 
121
-			$expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) );
121
+			$expr[] = $search->compare('==', $cmpfunc, count($refIds));
122 122
 		}
123 123
 
124
-		$search->setConditions( $search->combine( '&&', $expr ) );
124
+		$search->setConditions($search->combine('&&', $expr));
125 125
 
126
-		if( count( $productManager->searchItems( $search, [] ) ) === 0 )
126
+		if (count($productManager->searchItems($search, [])) === 0)
127 127
 		{
128
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid "%1$s" references for product with ID %2$s' );
129
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $domain, json_encode( $prodId ) ) );
128
+			$msg = $context->getI18n()->dt('controller/frontend', 'Invalid "%1$s" references for product with ID %2$s');
129
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $domain, json_encode($prodId)));
130 130
 		}
131 131
 	}
132 132
 
@@ -137,40 +137,40 @@  discard block
 block discarded – undo
137 137
 	 * @param \Aimeos\MShop\Locale\Item\Iface $locale Locale object from current basket
138 138
 	 * @param string $type Basket type
139 139
 	 */
140
-	protected function checkLocale( \Aimeos\MShop\Locale\Item\Iface $locale, $type )
140
+	protected function checkLocale(\Aimeos\MShop\Locale\Item\Iface $locale, $type)
141 141
 	{
142 142
 		$errors = [];
143 143
 		$context = $this->getContext();
144 144
 		$session = $context->getSession();
145 145
 
146
-		$localeStr = $session->get( 'aimeos/basket/locale' );
146
+		$localeStr = $session->get('aimeos/basket/locale');
147 147
 		$localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId();
148 148
 
149
-		if( $localeStr !== null && $localeStr !== $localeKey )
149
+		if ($localeStr !== null && $localeStr !== $localeKey)
150 150
 		{
151
-			$locParts = explode( '|', $localeStr );
152
-			$locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' );
153
-			$locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' );
154
-			$locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' );
151
+			$locParts = explode('|', $localeStr);
152
+			$locSite = (isset($locParts[0]) ? $locParts[0] : '');
153
+			$locLanguage = (isset($locParts[1]) ? $locParts[1] : '');
154
+			$locCurrency = (isset($locParts[2]) ? $locParts[2] : '');
155 155
 
156
-			$localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
157
-			$locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false );
156
+			$localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale');
157
+			$locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false);
158 158
 
159 159
 			$context = clone $context;
160
-			$context->setLocale( $locale );
160
+			$context->setLocale($locale);
161 161
 
162
-			$manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' );
163
-			$basket = $manager->getSession( $type );
162
+			$manager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
163
+			$basket = $manager->getSession($type);
164 164
 
165
-			$this->copyAddresses( $basket, $errors, $localeKey );
166
-			$this->copyServices( $basket, $errors );
167
-			$this->copyProducts( $basket, $errors, $localeKey );
168
-			$this->copyCoupons( $basket, $errors, $localeKey );
165
+			$this->copyAddresses($basket, $errors, $localeKey);
166
+			$this->copyServices($basket, $errors);
167
+			$this->copyProducts($basket, $errors, $localeKey);
168
+			$this->copyCoupons($basket, $errors, $localeKey);
169 169
 
170
-			$manager->setSession( $basket, $type );
170
+			$manager->setSession($basket, $type);
171 171
 		}
172 172
 
173
-		$session->set( 'aimeos/basket/locale', $localeKey );
173
+		$session->set('aimeos/basket/locale', $localeKey);
174 174
 	}
175 175
 
176 176
 
@@ -182,22 +182,22 @@  discard block
 block discarded – undo
182 182
 	 * @param string $localeKey Unique identifier of the site, language and currency
183 183
 	 * @return array Associative list of errors occured
184 184
 	 */
185
-	protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
185
+	protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
186 186
 	{
187
-		foreach( $basket->getAddresses() as $type => $item )
187
+		foreach ($basket->getAddresses() as $type => $item)
188 188
 		{
189 189
 			try
190 190
 			{
191
-				$this->setAddress( $type, $item->toArray() );
192
-				$basket->deleteAddress( $type );
191
+				$this->setAddress($type, $item->toArray());
192
+				$basket->deleteAddress($type);
193 193
 			}
194
-			catch( \Exception $e )
194
+			catch (\Exception $e)
195 195
 			{
196 196
 				$logger = $this->getContext()->getLogger();
197 197
 				$errors['address'][$type] = $e->getMessage();
198 198
 
199 199
 				$str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s';
200
-				$logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
200
+				$logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
201 201
 			}
202 202
 		}
203 203
 
@@ -213,22 +213,22 @@  discard block
 block discarded – undo
213 213
 	 * @param string $localeKey Unique identifier of the site, language and currency
214 214
 	 * @return array Associative list of errors occured
215 215
 	 */
216
-	protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
216
+	protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
217 217
 	{
218
-		foreach( $basket->getCoupons() as $code => $list )
218
+		foreach ($basket->getCoupons() as $code => $list)
219 219
 		{
220 220
 			try
221 221
 			{
222
-				$this->addCoupon( $code );
223
-				$basket->deleteCoupon( $code, true );
222
+				$this->addCoupon($code);
223
+				$basket->deleteCoupon($code, true);
224 224
 			}
225
-			catch( \Exception $e )
225
+			catch (\Exception $e)
226 226
 			{
227 227
 				$logger = $this->getContext()->getLogger();
228 228
 				$errors['coupon'][$code] = $e->getMessage();
229 229
 
230 230
 				$str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s';
231
-				$logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
231
+				$logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
232 232
 			}
233 233
 		}
234 234
 
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
 	 * @param string $localeKey Unique identifier of the site, language and currency
245 245
 	 * @return array Associative list of errors occured
246 246
 	 */
247
-	protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
247
+	protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
248 248
 	{
249
-		foreach( $basket->getProducts() as $pos => $product )
249
+		foreach ($basket->getProducts() as $pos => $product)
250 250
 		{
251
-			if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) {
251
+			if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) {
252 252
 				continue;
253 253
 			}
254 254
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 			{
257 257
 				$attrIds = [];
258 258
 
259
-				foreach( $product->getAttributes() as $attrItem ) {
259
+				foreach ($product->getAttributes() as $attrItem) {
260 260
 					$attrIds[$attrItem->getType()][] = $attrItem->getAttributeId();
261 261
 				}
262 262
 
@@ -264,22 +264,22 @@  discard block
 block discarded – undo
264 264
 					$product->getProductId(),
265 265
 					$product->getQuantity(),
266 266
 					$product->getStockType(),
267
-					$this->getValue( $attrIds, 'variant', [] ),
268
-					$this->getValue( $attrIds, 'config', [] ),
269
-					$this->getValue( $attrIds, 'hidden', [] ),
270
-					$this->getValue( $attrIds, 'custom', [] )
267
+					$this->getValue($attrIds, 'variant', []),
268
+					$this->getValue($attrIds, 'config', []),
269
+					$this->getValue($attrIds, 'hidden', []),
270
+					$this->getValue($attrIds, 'custom', [])
271 271
 				);
272 272
 
273
-				$basket->deleteProduct( $pos );
273
+				$basket->deleteProduct($pos);
274 274
 			}
275
-			catch( \Exception $e )
275
+			catch (\Exception $e)
276 276
 			{
277 277
 				$code = $product->getProductCode();
278 278
 				$logger = $this->getContext()->getLogger();
279 279
 				$errors['product'][$pos] = $e->getMessage();
280 280
 
281 281
 				$str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s';
282
-				$logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
282
+				$logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
283 283
 			}
284 284
 		}
285 285
 
@@ -294,24 +294,24 @@  discard block
 block discarded – undo
294 294
 	 * @param array $errors Associative list of previous errors
295 295
 	 * @return array Associative list of errors occured
296 296
 	 */
297
-	protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors )
297
+	protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors)
298 298
 	{
299
-		foreach( $basket->getServices() as $type => $list )
299
+		foreach ($basket->getServices() as $type => $list)
300 300
 		{
301
-			foreach( $list as $item )
301
+			foreach ($list as $item)
302 302
 			{
303 303
 				try
304 304
 				{
305 305
 					$attributes = [];
306 306
 
307
-					foreach( $item->getAttributes() as $attrItem ) {
307
+					foreach ($item->getAttributes() as $attrItem) {
308 308
 						$attributes[$attrItem->getCode()] = $attrItem->getValue();
309 309
 					}
310 310
 
311
-					$this->addService( $type, $item->getServiceId(), $attributes );
312
-					$basket->deleteService( $type );
311
+					$this->addService($type, $item->getServiceId(), $attributes);
312
+					$basket->deleteService($type);
313 313
 				}
314
-				catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically
314
+				catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically
315 315
 			}
316 316
 		}
317 317
 
@@ -327,32 +327,32 @@  discard block
 block discarded – undo
327 327
 	 * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface
328 328
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one
329 329
 	 */
330
-	protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) )
330
+	protected function getAttributes(array $attributeIds, array $domains = array('price', 'text'))
331 331
 	{
332
-		if( empty( $attributeIds ) ) {
332
+		if (empty($attributeIds)) {
333 333
 			return [];
334 334
 		}
335 335
 
336
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
336
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
337 337
 
338
-		$search = $attributeManager->createSearch( true );
338
+		$search = $attributeManager->createSearch(true);
339 339
 		$expr = array(
340
-			$search->compare( '==', 'attribute.id', $attributeIds ),
340
+			$search->compare('==', 'attribute.id', $attributeIds),
341 341
 			$search->getConditions(),
342 342
 		);
343
-		$search->setConditions( $search->combine( '&&', $expr ) );
344
-		$search->setSlice( 0, 0x7fffffff );
343
+		$search->setConditions($search->combine('&&', $expr));
344
+		$search->setSlice(0, 0x7fffffff);
345 345
 
346
-		$attrItems = $attributeManager->searchItems( $search, $domains );
346
+		$attrItems = $attributeManager->searchItems($search, $domains);
347 347
 
348
-		if( count( $attrItems ) !== count( $attributeIds ) )
348
+		if (count($attrItems) !== count($attributeIds))
349 349
 		{
350 350
 			$i18n = $this->getContext()->getI18n();
351
-			$expected = implode( ',', $attributeIds );
352
-			$actual = implode( ',', array_keys( $attrItems ) );
353
-			$msg = $i18n->dt( 'controller/frontend', 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"' );
351
+			$expected = implode(',', $attributeIds);
352
+			$actual = implode(',', array_keys($attrItems));
353
+			$msg = $i18n->dt('controller/frontend', 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"');
354 354
 
355
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $actual, $expected ) );
355
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $actual, $expected));
356 356
 		}
357 357
 
358 358
 		return $attrItems;
@@ -365,31 +365,31 @@  discard block
 block discarded – undo
365 365
 	 * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items
366 366
 	 * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values
367 367
 	 */
368
-	protected function getAttributeItems( array $orderAttributes )
368
+	protected function getAttributeItems(array $orderAttributes)
369 369
 	{
370
-		if( empty( $orderAttributes ) ) {
370
+		if (empty($orderAttributes)) {
371 371
 			return [];
372 372
 		}
373 373
 
374
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
375
-		$search = $attributeManager->createSearch( true );
374
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
375
+		$search = $attributeManager->createSearch(true);
376 376
 		$expr = [];
377 377
 
378
-		foreach( $orderAttributes as $item )
378
+		foreach ($orderAttributes as $item)
379 379
 		{
380 380
 			$tmp = array(
381
-				$search->compare( '==', 'attribute.domain', 'product' ),
382
-				$search->compare( '==', 'attribute.code', $item->getValue() ),
383
-				$search->compare( '==', 'attribute.type.domain', 'product' ),
384
-				$search->compare( '==', 'attribute.type.code', $item->getCode() ),
385
-				$search->compare( '>', 'attribute.type.status', 0 ),
381
+				$search->compare('==', 'attribute.domain', 'product'),
382
+				$search->compare('==', 'attribute.code', $item->getValue()),
383
+				$search->compare('==', 'attribute.type.domain', 'product'),
384
+				$search->compare('==', 'attribute.type.code', $item->getCode()),
385
+				$search->compare('>', 'attribute.type.status', 0),
386 386
 				$search->getConditions(),
387 387
 			);
388
-			$expr[] = $search->combine( '&&', $tmp );
388
+			$expr[] = $search->combine('&&', $tmp);
389 389
 		}
390 390
 
391
-		$search->setConditions( $search->combine( '||', $expr ) );
392
-		return $attributeManager->searchItems( $search, array( 'price' ) );
391
+		$search->setConditions($search->combine('||', $expr));
392
+		return $attributeManager->searchItems($search, array('price'));
393 393
 	}
394 394
 
395 395
 
@@ -402,24 +402,24 @@  discard block
 block discarded – undo
402 402
 	 * @param array $quantities Associative list of attribute IDs as keys and their quantities as values
403 403
 	 * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface
404 404
 	 */
405
-	protected function getOrderProductAttributes( $type, array $ids, array $values = [], array $quantities = [] )
405
+	protected function getOrderProductAttributes($type, array $ids, array $values = [], array $quantities = [])
406 406
 	{
407
-		if( empty( $ids ) ) {
407
+		if (empty($ids)) {
408 408
 			return [];
409 409
 		}
410 410
 
411 411
 		$list = [];
412
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' );
412
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute');
413 413
 
414
-		foreach( $this->getAttributes( $ids ) as $id => $attrItem )
414
+		foreach ($this->getAttributes($ids) as $id => $attrItem)
415 415
 		{
416 416
 			$item = $manager->createItem();
417
-			$item->copyFrom( $attrItem );
418
-			$item->setType( $type );
419
-			$item->setQuantity( isset( $quantities[$id] ) ? $quantities[$id] : 1 );
417
+			$item->copyFrom($attrItem);
418
+			$item->setType($type);
419
+			$item->setQuantity(isset($quantities[$id]) ? $quantities[$id] : 1);
420 420
 
421
-			if( isset( $values[$id] ) ) {
422
-				$item->setValue( $values[$id] );
421
+			if (isset($values[$id])) {
422
+				$item->setValue($values[$id]);
423 423
 			}
424 424
 
425 425
 			$list[] = $item;
@@ -436,23 +436,23 @@  discard block
 block discarded – undo
436 436
 	 * @param string $code Code of the list type
437 437
 	 * @return \Aimeos\MShop\Common\Item\Type\Iface List type item
438 438
 	 */
439
-	protected function getProductListTypeItem( $domain, $code )
439
+	protected function getProductListTypeItem($domain, $code)
440 440
 	{
441 441
 		$context = $this->getContext();
442 442
 
443
-		if( empty( $this->listTypeItems ) )
443
+		if (empty($this->listTypeItems))
444 444
 		{
445
-			$manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' );
445
+			$manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type');
446 446
 
447
-			foreach( $manager->searchItems( $manager->createSearch( true ) ) as $item ) {
448
-				$this->listTypeItems[ $item->getDomain() ][ $item->getCode() ] = $item;
447
+			foreach ($manager->searchItems($manager->createSearch(true)) as $item) {
448
+				$this->listTypeItems[$item->getDomain()][$item->getCode()] = $item;
449 449
 			}
450 450
 		}
451 451
 
452
-		if( !isset( $this->listTypeItems[$domain][$code] ) )
452
+		if (!isset($this->listTypeItems[$domain][$code]))
453 453
 		{
454
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'List type for domain "%1$s" and code "%2$s" not found' );
455
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $domain, $code ) );
454
+			$msg = $context->getI18n()->dt('controller/frontend', 'List type for domain "%1$s" and code "%2$s" not found');
455
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $domain, $code));
456 456
 		}
457 457
 
458 458
 		return $this->listTypeItems[$domain][$code];
@@ -467,43 +467,43 @@  discard block
 block discarded – undo
467 467
 	 * @param array $domains Names of the domain items that should be fetched too
468 468
 	 * @return array List of products matching the given attributes
469 469
 	 */
470
-	protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds,
471
-			array $domains = array( 'attribute', 'media', 'price', 'text' ) )
470
+	protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds,
471
+			array $domains = array('attribute', 'media', 'price', 'text'))
472 472
 	{
473 473
 		$subProductIds = [];
474
-		foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) {
474
+		foreach ($productItem->getRefItems('product', 'default', 'default') as $item) {
475 475
 			$subProductIds[] = $item->getId();
476 476
 		}
477 477
 
478
-		if( count( $subProductIds ) === 0 ) {
478
+		if (count($subProductIds) === 0) {
479 479
 			return [];
480 480
 		}
481 481
 
482
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
483
-		$search = $productManager->createSearch( true );
482
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
483
+		$search = $productManager->createSearch(true);
484 484
 
485 485
 		$expr = array(
486
-			$search->compare( '==', 'product.id', $subProductIds ),
486
+			$search->compare('==', 'product.id', $subProductIds),
487 487
 			$search->getConditions(),
488 488
 		);
489 489
 
490
-		if( count( $variantAttributeIds ) > 0 )
490
+		if (count($variantAttributeIds) > 0)
491 491
 		{
492
-			foreach( $variantAttributeIds as $key => $id ) {
492
+			foreach ($variantAttributeIds as $key => $id) {
493 493
 				$variantAttributeIds[$key] = (string) $id;
494 494
 			}
495 495
 
496
-			$listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' );
496
+			$listTypeItem = $this->getProductListTypeItem('attribute', 'variant');
497 497
 
498
-			$param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds );
499
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
498
+			$param = array('attribute', $listTypeItem->getId(), $variantAttributeIds);
499
+			$cmpfunc = $search->createFunction('product.contains', $param);
500 500
 
501
-			$expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) );
501
+			$expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds));
502 502
 		}
503 503
 
504
-		$search->setConditions( $search->combine( '&&', $expr ) );
504
+		$search->setConditions($search->combine('&&', $expr));
505 505
 
506
-		return $productManager->searchItems( $search, $domains );
506
+		return $productManager->searchItems($search, $domains);
507 507
 	}
508 508
 
509 509
 
@@ -515,9 +515,9 @@  discard block
 block discarded – undo
515 515
 	 * @param mixed $default Default value if no value is available for the given name
516 516
 	 * @return mixed Value from the array or default value
517 517
 	 */
518
-	protected function getValue( array $values, $name, $default = null )
518
+	protected function getValue(array $values, $name, $default = null)
519 519
 	{
520
-		if( isset( $values[$name] ) ) {
520
+		if (isset($values[$name])) {
521 521
 			return $values[$name];
522 522
 		}
523 523
 
Please login to merge, or discard this patch.
controller/frontend/tests/Controller/Frontend/Basket/BaseTest.php 1 patch
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -21,46 +21,46 @@  discard block
 block discarded – undo
21 21
 
22 22
 	protected function tearDown()
23 23
 	{
24
-		$this->context->getSession()->set( 'aimeos', [] );
24
+		$this->context->getSession()->set('aimeos', []);
25 25
 
26
-		unset( $this->context );
26
+		unset($this->context);
27 27
 	}
28 28
 
29 29
 
30 30
 	public function testCheckLocale()
31 31
 	{
32
-		$object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' )
33
-			->setConstructorArgs( [$this->context] )
34
-			->setMethods( null )
32
+		$object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard')
33
+			->setConstructorArgs([$this->context])
34
+			->setMethods(null)
35 35
 			->getMock();
36 36
 
37
-		$this->context->getSession()->set( 'aimeos/basket/locale', 'unittest|en|EUR' );
38
-		$this->access( 'checkLocale' )->invokeArgs( $object, [$this->context->getLocale(), 'unittest'] );
37
+		$this->context->getSession()->set('aimeos/basket/locale', 'unittest|en|EUR');
38
+		$this->access('checkLocale')->invokeArgs($object, [$this->context->getLocale(), 'unittest']);
39 39
 	}
40 40
 
41 41
 
42 42
 	public function testCopyAddresses()
43 43
 	{
44
-		$manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' );
44
+		$manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base');
45 45
 		$ordBaseItem = $manager->createItem();
46 46
 
47
-		$address = $this->getAddress( 'Example company' );
48
-		$ordBaseItem->setAddress( $address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
47
+		$address = $this->getAddress('Example company');
48
+		$ordBaseItem->setAddress($address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
49 49
 
50 50
 
51
-		$object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' )
52
-			->setConstructorArgs( [$this->context] )
53
-			->setMethods( null )
51
+		$object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard')
52
+			->setConstructorArgs([$this->context])
53
+			->setMethods(null)
54 54
 			->getMock();
55 55
 
56
-		$result = $this->access( 'copyAddresses' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] );
56
+		$result = $this->access('copyAddresses')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']);
57 57
 
58 58
 
59
-		$this->assertEquals( ['test'], $result );
60
-		$this->assertEquals( 1, count( $object->get()->getAddresses() ) );
59
+		$this->assertEquals(['test'], $result);
60
+		$this->assertEquals(1, count($object->get()->getAddresses()));
61 61
 
62
-		$addr = $object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
63
-		$this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Address\Iface', $addr );
62
+		$addr = $object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
63
+		$this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Address\Iface', $addr);
64 64
 
65 65
 		$object->clear();
66 66
 	}
@@ -68,54 +68,54 @@  discard block
 block discarded – undo
68 68
 
69 69
 	public function testCopyAddressesException()
70 70
 	{
71
-		$manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' );
71
+		$manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base');
72 72
 		$ordBaseItem = $manager->createItem();
73 73
 
74
-		$address = $this->getAddress( 'Example company' );
75
-		$ordBaseItem->setAddress( $address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT );
74
+		$address = $this->getAddress('Example company');
75
+		$ordBaseItem->setAddress($address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT);
76 76
 
77 77
 
78
-		$object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' )
79
-			->setConstructorArgs( [$this->context] )
80
-			->setMethods( ['setAddress'] )
78
+		$object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard')
79
+			->setConstructorArgs([$this->context])
80
+			->setMethods(['setAddress'])
81 81
 			->getMock();
82 82
 
83
-		$object->expects( $this->once() )->method( 'setAddress' )->will( $this->throwException( new \Exception() ) );
83
+		$object->expects($this->once())->method('setAddress')->will($this->throwException(new \Exception()));
84 84
 
85
-		$result = $this->access( 'copyAddresses' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] );
85
+		$result = $this->access('copyAddresses')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']);
86 86
 
87
-		$this->assertEquals( 1, count( $result ) );
88
-		$this->assertArrayHasKey( 'address', $result );
87
+		$this->assertEquals(1, count($result));
88
+		$this->assertArrayHasKey('address', $result);
89 89
 	}
90 90
 
91 91
 
92 92
 	public function testCopyCoupon()
93 93
 	{
94
-		$manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' );
94
+		$manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base');
95 95
 		$ordBaseItem = $manager->createItem();
96 96
 
97
-		$product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC', ['price'] );
98
-		$ordProdManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/product' );
99
-		$ordProdItem = $ordProdManager->createItem()->copyFrom( $product );
97
+		$product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC', ['price']);
98
+		$ordProdManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/product');
99
+		$ordProdItem = $ordProdManager->createItem()->copyFrom($product);
100 100
 
101
-		$priceItems = $product->getRefItems( 'price' );
102
-		$ordProdItem->setPrice( reset( $priceItems ) );
101
+		$priceItems = $product->getRefItems('price');
102
+		$ordProdItem->setPrice(reset($priceItems));
103 103
 
104
-		$ordBaseItem->addProduct( $ordProdItem );
105
-		$ordBaseItem->addCoupon( 'OPQR', [] );
104
+		$ordBaseItem->addProduct($ordProdItem);
105
+		$ordBaseItem->addCoupon('OPQR', []);
106 106
 
107 107
 
108
-		$object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' )
109
-			->setConstructorArgs( [$this->context] )
110
-			->setMethods( null )
108
+		$object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard')
109
+			->setConstructorArgs([$this->context])
110
+			->setMethods(null)
111 111
 			->getMock();
112 112
 
113
-		$object->addProduct( $product->getId() );
113
+		$object->addProduct($product->getId());
114 114
 
115
-		$result = $this->access( 'copyCoupons' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] );
115
+		$result = $this->access('copyCoupons')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']);
116 116
 
117 117
 
118
-		$this->assertEquals( ['test'], $result );
118
+		$this->assertEquals(['test'], $result);
119 119
 
120 120
 		$object->clear();
121 121
 	}
@@ -123,48 +123,48 @@  discard block
 block discarded – undo
123 123
 
124 124
 	public function testCopyCouponException()
125 125
 	{
126
-		$manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' );
126
+		$manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base');
127 127
 		$ordBaseItem = $manager->createItem();
128 128
 
129
-		$ordBaseItem->addCoupon( '90AB', [] );
129
+		$ordBaseItem->addCoupon('90AB', []);
130 130
 
131 131
 
132
-		$object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' )
133
-			->setConstructorArgs( [$this->context] )
134
-			->setMethods( ['addCoupon'] )
132
+		$object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard')
133
+			->setConstructorArgs([$this->context])
134
+			->setMethods(['addCoupon'])
135 135
 			->getMock();
136 136
 
137
-		$object->expects( $this->once() )->method( 'addCoupon' )->will( $this->throwException( new \Exception() ) );
137
+		$object->expects($this->once())->method('addCoupon')->will($this->throwException(new \Exception()));
138 138
 
139
-		$result = $this->access( 'copyCoupons' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] );
139
+		$result = $this->access('copyCoupons')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']);
140 140
 
141
-		$this->assertEquals( 1, count( $result ) );
142
-		$this->assertArrayHasKey( 'coupon', $result );
141
+		$this->assertEquals(1, count($result));
142
+		$this->assertArrayHasKey('coupon', $result);
143 143
 	}
144 144
 
145 145
 
146 146
 	public function testCopyProduct()
147 147
 	{
148
-		$manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' );
148
+		$manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base');
149 149
 		$ordBaseItem = $manager->createItem();
150 150
 
151
-		$product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' );
152
-		$ordProdManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/product' );
153
-		$ordProdItem = $ordProdManager->createItem()->copyFrom( $product );
154
-		$ordBaseItem->addProduct( $ordProdItem );
151
+		$product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC');
152
+		$ordProdManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/product');
153
+		$ordProdItem = $ordProdManager->createItem()->copyFrom($product);
154
+		$ordBaseItem->addProduct($ordProdItem);
155 155
 
156 156
 
157
-		$object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' )
158
-			->setConstructorArgs( [$this->context] )
159
-			->setMethods( null )
157
+		$object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard')
158
+			->setConstructorArgs([$this->context])
159
+			->setMethods(null)
160 160
 			->getMock();
161 161
 
162
-		$result = $this->access( 'copyProducts' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] );
162
+		$result = $this->access('copyProducts')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']);
163 163
 
164 164
 
165
-		$this->assertEquals( ['test'], $result );
166
-		$this->assertEquals( 1, count( $object->get()->getProducts() ) );
167
-		$this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Product\Iface', $object->get()->getProduct( 0 ) );
165
+		$this->assertEquals(['test'], $result);
166
+		$this->assertEquals(1, count($object->get()->getProducts()));
167
+		$this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Product\Iface', $object->get()->getProduct(0));
168 168
 
169 169
 		$object->clear();
170 170
 	}
@@ -172,58 +172,58 @@  discard block
 block discarded – undo
172 172
 
173 173
 	public function testCopyProductException()
174 174
 	{
175
-		$manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' );
175
+		$manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base');
176 176
 		$ordBaseItem = $manager->createItem();
177 177
 
178
-		$product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' );
179
-		$ordProdManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/product' );
180
-		$ordProdItem = $ordProdManager->createItem()->copyFrom( $product );
181
-		$ordBaseItem->addProduct( $ordProdItem );
178
+		$product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC');
179
+		$ordProdManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/product');
180
+		$ordProdItem = $ordProdManager->createItem()->copyFrom($product);
181
+		$ordBaseItem->addProduct($ordProdItem);
182 182
 
183 183
 
184
-		$object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' )
185
-			->setConstructorArgs( [$this->context] )
186
-			->setMethods( ['addProduct'] )
184
+		$object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard')
185
+			->setConstructorArgs([$this->context])
186
+			->setMethods(['addProduct'])
187 187
 			->getMock();
188 188
 
189
-		$object->expects( $this->once() )->method( 'addProduct' )->will( $this->throwException( new \Exception() ) );
189
+		$object->expects($this->once())->method('addProduct')->will($this->throwException(new \Exception()));
190 190
 
191
-		$result = $this->access( 'copyProducts' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] );
191
+		$result = $this->access('copyProducts')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']);
192 192
 
193
-		$this->assertEquals( 1, count( $result ) );
194
-		$this->assertArrayHasKey( 'product', $result );
193
+		$this->assertEquals(1, count($result));
194
+		$this->assertArrayHasKey('product', $result);
195 195
 	}
196 196
 
197 197
 
198 198
 	public function testCopyServices()
199 199
 	{
200
-		$manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' );
200
+		$manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base');
201 201
 		$ordBaseItem = $manager->createItem();
202 202
 
203
-		$serviceManager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
204
-		$ordServManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/service' );
203
+		$serviceManager = \Aimeos\MShop\Factory::createManager($this->context, 'service');
204
+		$ordServManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/service');
205 205
 
206
-		$serviceItem = $serviceManager->findItem( 'unitcode', [], 'service', 'delivery' );
207
-		$ordServItem = $ordServManager->createItem()->copyFrom( $serviceItem );
206
+		$serviceItem = $serviceManager->findItem('unitcode', [], 'service', 'delivery');
207
+		$ordServItem = $ordServManager->createItem()->copyFrom($serviceItem);
208 208
 
209
-		$ordBaseItem->addService( $ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY );
209
+		$ordBaseItem->addService($ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY);
210 210
 
211 211
 
212
-		$object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' )
213
-			->setConstructorArgs( [$this->context] )
214
-			->setMethods( null )
212
+		$object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard')
213
+			->setConstructorArgs([$this->context])
214
+			->setMethods(null)
215 215
 			->getMock();
216 216
 
217
-		$result = $this->access( 'copyServices' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] );
217
+		$result = $this->access('copyServices')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']);
218 218
 
219 219
 
220
-		$this->assertEquals( ['test'], $result );
221
-		$this->assertEquals( 1, count( $object->get()->getServices() ) );
220
+		$this->assertEquals(['test'], $result);
221
+		$this->assertEquals(1, count($object->get()->getServices()));
222 222
 
223
-		$services = $object->get()->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY );
223
+		$services = $object->get()->getService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY);
224 224
 
225
-		foreach( $services as $service ) {
226
-			$this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Service\Iface', $service );
225
+		foreach ($services as $service) {
226
+			$this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Service\Iface', $service);
227 227
 		}
228 228
 
229 229
 		$object->clear();
@@ -232,75 +232,75 @@  discard block
 block discarded – undo
232 232
 
233 233
 	public function testCopyServicesException()
234 234
 	{
235
-		$manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' );
235
+		$manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base');
236 236
 		$ordBaseItem = $manager->createItem();
237 237
 
238
-		$serviceManager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' );
239
-		$ordServManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/service' );
238
+		$serviceManager = \Aimeos\MShop\Factory::createManager($this->context, 'service');
239
+		$ordServManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/service');
240 240
 
241
-		$serviceItem = $serviceManager->findItem( 'unitcode', [], 'service', 'delivery' );
242
-		$ordServItem = $ordServManager->createItem()->copyFrom( $serviceItem );
241
+		$serviceItem = $serviceManager->findItem('unitcode', [], 'service', 'delivery');
242
+		$ordServItem = $ordServManager->createItem()->copyFrom($serviceItem);
243 243
 
244
-		$ordBaseItem->addService( $ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY );
244
+		$ordBaseItem->addService($ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY);
245 245
 
246 246
 
247
-		$object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' )
248
-			->setConstructorArgs( [$this->context] )
249
-			->setMethods( ['addService'] )
247
+		$object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard')
248
+			->setConstructorArgs([$this->context])
249
+			->setMethods(['addService'])
250 250
 			->getMock();
251 251
 
252
-		$object->expects( $this->once() )->method( 'addService' )->will( $this->throwException( new \Exception() ) );
252
+		$object->expects($this->once())->method('addService')->will($this->throwException(new \Exception()));
253 253
 
254
-		$result = $this->access( 'copyServices' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] );
254
+		$result = $this->access('copyServices')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']);
255 255
 
256
-		$this->assertEquals( 0, count( $result ) );
256
+		$this->assertEquals(0, count($result));
257 257
 	}
258 258
 
259 259
 
260 260
 	public function testGetOrderProductAttributes()
261 261
 	{
262
-		$object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' )
263
-			->setConstructorArgs( [$this->context] )
264
-			->setMethods( ['getAttributes'] )
262
+		$object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard')
263
+			->setConstructorArgs([$this->context])
264
+			->setMethods(['getAttributes'])
265 265
 			->getMock();
266 266
 
267
-		$list = [1 => new \Aimeos\MShop\Attribute\Item\Standard( ['attribute.code' => 'special_instructions'] )];
268
-		$object->expects( $this->once() )->method( 'getAttributes' )->will( $this->returnValue( $list ) );
267
+		$list = [1 => new \Aimeos\MShop\Attribute\Item\Standard(['attribute.code' => 'special_instructions'])];
268
+		$object->expects($this->once())->method('getAttributes')->will($this->returnValue($list));
269 269
 
270
-		$result = $this->access( 'getOrderProductAttributes' )->invokeArgs( $object, ['test', ['1'], ['1' => 'test']] );
270
+		$result = $this->access('getOrderProductAttributes')->invokeArgs($object, ['test', ['1'], ['1' => 'test']]);
271 271
 
272
-		$this->assertEquals( 1, count( $result ) );
273
-		$this->assertEquals( 'test', $result[0]->getValue() );
272
+		$this->assertEquals(1, count($result));
273
+		$this->assertEquals('test', $result[0]->getValue());
274 274
 	}
275 275
 
276 276
 
277 277
 	/**
278 278
 	 * @param string $company
279 279
 	 */
280
-	protected function getAddress( $company )
280
+	protected function getAddress($company)
281 281
 	{
282
-		$manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'customer/address' );
282
+		$manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'customer/address');
283 283
 
284 284
 		$search = $manager->createSearch();
285
-		$search->setConditions( $search->compare( '==', 'customer.address.company', $company ) );
286
-		$items = $manager->searchItems( $search );
285
+		$search->setConditions($search->compare('==', 'customer.address.company', $company));
286
+		$items = $manager->searchItems($search);
287 287
 
288
-		if( ( $item = reset( $items ) ) === false ) {
289
-			throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) );
288
+		if (($item = reset($items)) === false) {
289
+			throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company));
290 290
 		}
291 291
 
292
-		$ordAddrManager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base/address' );
293
-		$ordAddrItem = $ordAddrManager->createItem()->copyFrom( $item );
292
+		$ordAddrManager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base/address');
293
+		$ordAddrItem = $ordAddrManager->createItem()->copyFrom($item);
294 294
 
295 295
 		return $ordAddrItem;
296 296
 	}
297 297
 
298 298
 
299
-	protected function access( $name )
299
+	protected function access($name)
300 300
 	{
301
-		$class = new \ReflectionClass( '\Aimeos\Controller\Frontend\Basket\Base' );
302
-		$method = $class->getMethod( $name );
303
-		$method->setAccessible( true );
301
+		$class = new \ReflectionClass('\Aimeos\Controller\Frontend\Basket\Base');
302
+		$method = $class->getMethod($name);
303
+		$method->setAccessible(true);
304 304
 
305 305
 		return $method;
306 306
 	}
Please login to merge, or discard this patch.