Base::getMapping()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2025
6
 * @package Controller
7
 * @subpackage Common
8
 */
9
10
11
namespace Aimeos\Controller\Jobs\Common\Coupon\Import\Csv\Processor;
12
13
14
/**
15
 * Abstract class with common methods for all CSV import processors
16
 *
17
 * @package Controller
18
 * @subpackage Common
19
 */
20
class Base
21
	extends \Aimeos\Controller\Jobs\Common\Coupon\Import\Csv\Base
22
{
23
	private \Aimeos\Controller\Jobs\Common\Coupon\Import\Csv\Processor\Iface $object;
24
	private \Aimeos\MShop\ContextIface $context;
25
	private array $mapping;
26
27
28
	/**
29
	 * Initializes the object
30
	 *
31
	 * @param \Aimeos\MShop\ContextIface $context Context object
32
	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
33
	 * @param \Aimeos\Controller\Jobs\Common\Coupon\Import\Csv\Processor\Iface $object Decorated processor
34
	 */
35
	public function __construct( \Aimeos\MShop\ContextIface $context, array $mapping,
36
		?\Aimeos\Controller\Jobs\Common\Coupon\Import\Csv\Processor\Iface $object = null )
37
	{
38
		$this->context = $context;
39
		$this->mapping = $mapping;
40
		$this->object = $object;
41
	}
42
43
44
	/**
45
	 * Returns the context item
46
	 *
47
	 * @return \Aimeos\MShop\ContextIface Context object
48
	 */
49
	protected function context() : \Aimeos\MShop\ContextIface
50
	{
51
		return $this->context;
52
	}
53
54
55
	/**
56
	 * Returns the mapping list
57
	 *
58
	 * @return array Associative list of field positions in CSV as keys and domain item keys as values
59
	 */
60
	protected function getMapping() : array
61
	{
62
		return $this->mapping;
63
	}
64
65
66
	/**
67
	 * Returns the decorated processor object
68
	 *
69
	 * @return \Aimeos\Controller\Jobs\Common\Coupon\Import\Csv\Processor\Iface Processor object
70
	 * @throws \Aimeos\Controller\Jobs\Exception If no processor object is available
71
	 */
72
	protected function object() : \Aimeos\Controller\Jobs\Common\Coupon\Import\Csv\Processor\Iface
73
	{
74
		if( $this->object === null ) {
75
			throw new \Aimeos\Controller\Jobs\Exception( 'No processor object available' );
76
		}
77
78
		return $this->object;
79
	}
80
}
81