Passed
Push — master ( 49c0d4...ffd40d )
by Aimeos
19:25 queued 16:39
created

Standard   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 9 2
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2019-2022
6
 * @package MW
7
 * @subpackage View
8
 */
9
10
11
namespace Aimeos\Base\View\Helper\Typemap;
12
13
14
/**
15
 * View helper class for mapping items by type
16
 *
17
 * @package MW
18
 * @subpackage View
19
 */
20
class Standard
21
	extends \Aimeos\Base\View\Helper\Base
22
	implements \Aimeos\Base\View\Helper\Typemap\Iface
23
{
24
	/**
25
	 * Returns a map with type/ID/item structure
26
	 *
27
	 * @param \Aimeos\Map $items List of items implementing \Aimeos\MShop\Common\Item\Type\Iface
28
	 * @return \Aimeos\Map Map with type/ID/item structure
29
	 */
30
	public function transform( \Aimeos\Map $items ) : \Aimeos\Map
31
	{
32
		$map = [];
33
34
		foreach( $items as $item ) {
35
			$map[$item->getType()][$item->getId()] = $item;
36
		}
37
38
		return map( $map );
39
	}
40
}
41