Completed
Push — master ( 0010c2...5cb668 )
by Aimeos
02:18
created

Standard::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 3
nop 2
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017
6
 * @package Controller
7
 * @subpackage Common
8
 */
9
10
11
namespace Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code;
12
13
14
/**
15
 * Coupon code processor for CSV imports
16
 *
17
 * @package Controller
18
 * @subpackage Common
19
 */
20
class Standard
21
	extends \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Base
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
Coding Style introduced by
Expected 0 spaces between "Base" and comma; 1 found
Loading history...
22
	implements \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface
0 ignored issues
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
23
{
24
	/** controller/common/coupon/import/csv/processor/code/name
25
	 * Name of the coupon code processor implementation
26
	 *
27
	 * Use "Myname" if your class is named "\Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Code\Myname".
28
	 * The name is case-sensitive and you should avoid camel case names like "MyName".
29
	 *
30
	 * @param string Last part of the processor class name
31
	 * @since 2017.10
32
	 * @category Developer
33
	 */
34
35
36
	/**
37
	 * Saves the coupon code related data to the storage
38
	 *
39
	 * @param \Aimeos\MShop\Coupon\Item\Code\Iface $item Coupon code object
40
	 * @param array $data List of CSV fields with position as key and data as value
41
	 * @return array List of data which hasn't been imported
42
	 */
43
	public function process( \Aimeos\MShop\Coupon\Item\Code\Iface $item, array $data )
44
	{
45
		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' );
46
		$map = $this->getMappedChunk( $data, $this->getMapping() );
47
48
		foreach( $map as $list )
49
		{
50
			if( $list['coupon.code.code'] == '' ) {
51
				continue;
52
			}
53
54
			$item->fromArray( $list );
55
			$manager->saveItem( $item );
56
		}
57
58
		return $this->getObject()->process( $item, $data );
59
	}
60
}
61