Passed
Push — master ( 2e8fc6...fa4386 )
by Aimeos
03:53
created

Standard::checkEntry()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2025
6
 * @package Controller
7
 * @subpackage Common
8
 */
9
10
11
namespace Aimeos\Controller\Jobs\Common\Customer\Import\Csv\Processor\Address;
12
13
14
/**
15
 * Address processor for CSV imports
16
 *
17
 * @package Controller
18
 * @subpackage Common
19
 */
20
class Standard
21
	extends \Aimeos\Controller\Jobs\Common\Customer\Import\Csv\Processor\Base
22
	implements \Aimeos\Controller\Jobs\Common\Customer\Import\Csv\Processor\Iface
23
{
24
	/** controller/jobs/customer/import/csv/processor/address/name
25
	 * Name of the address processor implementation
26
	 *
27
	 * Use "Myname" if your class is named "\Aimeos\Controller\Jobs\Common\Customer\Import\Csv\Processor\Address\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 2025.10
32
	 */
33
34
35
	/**
36
	 * Saves the customer related data to the storage
37
	 *
38
	 * @param \Aimeos\MShop\Customer\Item\Iface $customer Customer item with associated items
39
	 * @param array $data List of CSV fields with position as key and data as value
40
	 * @return array List of data which hasn't been imported
41
	 */
42
	public function process( \Aimeos\MShop\Customer\Item\Iface $customer, array $data ) : array
43
	{
44
		$context = $this->context();
45
		$manager = \Aimeos\MShop::create( $context, 'customer' );
46
47
		$pos = 0;
48
		$map = $this->getMappedChunk( $data, $this->getMapping() );
49
		$addresses = $customer->getAddressItems();
50
51
		foreach( $map as $entry )
52
		{
53
			$key = $addresses->firstKey();
54
			$address = $addresses->pull( $key ) ?? $manager->createAddressItem();
0 ignored issues
show
Bug introduced by
The method createAddressItem() does not exist on Aimeos\MShop\Common\Manager\Iface. Did you maybe mean create()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
			$address = $addresses->pull( $key ) ?? $manager->/** @scrutinizer ignore-call */ createAddressItem();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
55
			$address->setPosition( $pos++ )->fromArray( $entry );
56
57
			$customer->addAddressItem( $address, $key );
58
		}
59
60
		$customer->deleteAddressItems( $addresses );
61
62
		return $this->object()->process( $customer, $data );
63
	}
64
}
65