Completed
Push — master ( f97bb5...a4e8a9 )
by Aimeos
02:10
created

Standard::searchItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
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 Frontend
8
 */
9
10
11
namespace Aimeos\Controller\Frontend\Stock;
12
13
14
/**
15
 * Default implementation of the stock frontend controller
16
 *
17
 * @package Controller
18
 * @subpackage Frontend
19
 */
20
class Standard
21
	extends \Aimeos\Controller\Frontend\Base
2 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 Iface, \Aimeos\Controller\Frontend\Common\Iface
1 ignored issue
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
23
{
24
	/**
25
	 * Returns the given search filter with the conditions attached for filtering by product code
26
	 *
27
	 * @param \Aimeos\MW\Criteria\Iface $filter Criteria object used for stock search
28
	 * @param array $codes List of product codes
29
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
30
	 * @since 2017.03
31
	 */
32
	public function addFilterCodes( \Aimeos\MW\Criteria\Iface $filter, array $codes )
33
	{
34
		$expr = [
35
			$filter->compare( '==', 'stock.productcode', $codes ),
36
			$filter->getConditions(),
37
		];
38
		$filter->setConditions( $filter->combine( '&&', $expr ) );
39
40
		return $filter;
41
	}
42
43
44
	/**
45
	 * Returns the given search filter with the conditions attached for filtering by type code
46
	 *
47
	 * @param \Aimeos\MW\Criteria\Iface $filter Criteria object used for stock search
48
	 * @param array $codes List of stock type codes
49
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
50
	 * @since 2017.03
51
	 */
52
	public function addFilterTypes( \Aimeos\MW\Criteria\Iface $filter, array $codes )
53
	{
54
		if( !empty( $codes ) )
55
		{
56
			$expr = [
57
				$filter->compare( '==', 'stock.type.code', $codes ),
58
				$filter->getConditions(),
59
			];
60
			$filter->setConditions( $filter->combine( '&&', $expr ) );
61
		}
62
63
		return $filter;
64
	}
65
66
67
	/**
68
	 * Returns the default stock filter
69
	 *
70
	 * @param boolean True to add default criteria
71
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
72
	 * @since 2017.03
73
	 */
74
	public function createFilter()
75
	{
76
		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' )->createSearch( true );
77
	}
78
79
80
	/**
81
	 * Returns the stock item for the given stock ID
82
	 *
83
	 * @param string $id Unique stock ID
84
	 * @param string[] $domains Domain names of items that are associated with the stocks and that should be fetched too
0 ignored issues
show
Bug introduced by
There is no parameter named $domains. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
85
	 * @return \Aimeos\MShop\Stock\Item\Iface Stock item including the referenced domains items
86
	 * @since 2017.03
87
	 */
88
	public function getItem( $id )
89
	{
90
		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' )->getItem( $id );
91
	}
92
93
94
	/**
95
	 * Returns the stocks filtered by the given criteria object
96
	 *
97
	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
98
	 * @param integer &$total Parameter where the total number of found stocks will be stored in
99
	 * @return array Ordered list of stock items implementing \Aimeos\MShop\Stock\Item\Iface
100
	 * @since 2017.03
101
	 */
102
	public function searchItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null )
103
	{
104
		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'stock' )->searchItems( $filter, [], $total );
105
	}
106
}
107