Completed
Push — master ( 9109fd...709bda )
by Aimeos
02:33
created

Base::compare()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2018
6
 * @package Controller
7
 * @subpackage Frontend
8
 */
9
10
11
namespace Aimeos\Controller\Frontend\Stock\Decorator;
12
13
14
/**
15
 * Base for stock frontend controller decorators
16
 *
17
 * @package Controller
18
 * @subpackage Frontend
19
 */
20
abstract class Base
21
	extends \Aimeos\Controller\Frontend\Base
22
	implements \Aimeos\Controller\Frontend\Common\Decorator\Iface, \Aimeos\Controller\Frontend\Stock\Iface
23
{
24
	private $controller;
25
26
27
	/**
28
	 * Initializes the controller decorator.
29
	 *
30
	 * @param \Aimeos\Controller\Frontend\Iface $controller Controller object
31
	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects
32
	 */
33
	public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context )
34
	{
35
		$iface = \Aimeos\Controller\Frontend\Stock\Iface::class;
36
		$this->controller = \Aimeos\MW\Common\Base::checkClass( $iface, $controller );
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $this->controller is correct as \Aimeos\MW\Common\Base::...ss($iface, $controller) (which targets Aimeos\MW\Common\Base::checkClass()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
37
38
		parent::__construct( $context );
39
	}
40
41
42
	/**
43
	 * Passes unknown methods to wrapped objects.
44
	 *
45
	 * @param string $name Name of the method
46
	 * @param array $param List of method parameter
47
	 * @return mixed Returns the value of the called method
48
	 * @throws \Aimeos\Controller\Frontend\Exception If method call failed
49
	 */
50
	public function __call( $name, array $param )
51
	{
52
		return @call_user_func_array( array( $this->controller, $name ), $param );
53
	}
54
55
56
	/**
57
	 * Adds the SKUs of the products for filtering
58
	 *
59
	 * @param array|string $codes Codes of the products
60
	 * @return \Aimeos\Controller\Frontend\Stock\Iface Stock controller for fluent interface
61
	 * @since 2019.04
62
	 */
63
	public function code( $codes )
64
	{
65
		$this->controller->code( $codes );
0 ignored issues
show
Bug introduced by
The method code cannot be called on $this->controller (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
66
		return $this;
67
	}
68
69
70
	/**
71
	 * Adds generic condition for filtering
72
	 *
73
	 * @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~="
74
	 * @param string $key Search key defined by the stock manager, e.g. "stock.dateback"
75
	 * @param array|string $value Value or list of values to compare to
76
	 * @return \Aimeos\Controller\Frontend\Stock\Iface Stock controller for fluent interface
77
	 * @since 2019.04
78
	 */
79
	public function compare( $operator, $key, $value )
80
	{
81
		$this->controller->compare( $operator, $key, $value );
0 ignored issues
show
Bug introduced by
The method compare cannot be called on $this->controller (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
82
		return $this;
83
	}
84
85
86
	/**
87
	 * Returns the stock item for the given stock ID
88
	 *
89
	 * @param string $id Unique stock ID
90
	 * @return \Aimeos\MShop\Stock\Item\Iface Stock item
91
	 * @since 2019.04
92
	 */
93
	public function get( $id )
94
	{
95
		return $this->controller->get( $id );
0 ignored issues
show
Bug introduced by
The method get cannot be called on $this->controller (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
96
	}
97
98
99
	/**
100
	 * Returns the stock item for the given SKU and type
101
	 *
102
	 * @param string $code Unique stock code
103
	 * @param string $type Type assigned to the stock item
104
	 * @return \Aimeos\MShop\Stock\Item\Iface Stock item
105
	 * @since 2019.04
106
	 */
107
	public function find( $code, $type )
108
	{
109
		return $this->controller->find( $code, $type );
0 ignored issues
show
Bug introduced by
The method find cannot be called on $this->controller (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
110
	}
111
112
113
	/**
114
	 * Parses the given array and adds the conditions to the list of conditions
115
	 *
116
	 * @param array $conditions List of conditions, e.g. ['>' => ['stock.dateback' => '2000-01-01 00:00:00']]
117
	 * @return \Aimeos\Controller\Frontend\Stock\Iface Stock controller for fluent interface
118
	 * @since 2019.04
119
	 */
120
	public function parse( array $conditions )
121
	{
122
		$this->controller->parse( $conditions );
0 ignored issues
show
Bug introduced by
The method parse cannot be called on $this->controller (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
123
		return $this;
124
	}
125
126
127
	/**
128
	 * Returns the stock items filtered by the previously assigned conditions
129
	 *
130
	 * @param integer &$total Parameter where the total number of found stock items will be stored in
131
	 * @return \Aimeos\MShop\Stock\Item\Iface[] Ordered list of stock items
132
	 * @since 2019.04
133
	 */
134
	public function search( &$total = null )
135
	{
136
		return $this->controller->search( $total );
0 ignored issues
show
Bug introduced by
The method search cannot be called on $this->controller (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
137
	}
138
139
140
	/**
141
	 * Sets the start value and the number of returned stock items for slicing the list of found stock items
142
	 *
143
	 * @param integer $start Start value of the first stock item in the list
144
	 * @param integer $limit Number of returned stock items
145
	 * @return \Aimeos\Controller\Frontend\Stock\Iface Stock controller for fluent interface
146
	 * @since 2019.04
147
	 */
148
	public function slice( $start, $limit )
149
	{
150
		$this->controller->slice( $start, $limit );
0 ignored issues
show
Bug introduced by
The method slice cannot be called on $this->controller (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
151
		return $this;
152
	}
153
154
155
	/**
156
	 * Sets the sorting of the result list
157
	 *
158
	 * @param string|null $key Sorting of the result list like "stock.type", null for no sorting
159
	 * @return \Aimeos\Controller\Frontend\Stock\Iface Stock controller for fluent interface
160
	 * @since 2019.04
161
	 */
162
	public function sort( $key = null )
163
	{
164
		$this->controller->sort( $key );
0 ignored issues
show
Bug introduced by
The method sort cannot be called on $this->controller (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
165
		return $this;
166
	}
167
168
169
	/**
170
	 * Adds stock types for filtering
171
	 *
172
	 * @param array|string $types Stock type codes
173
	 * @return \Aimeos\Controller\Frontend\Stock\Iface Stock controller for fluent interface
174
	 * @since 2019.04
175
	 */
176
	public function type( $types )
177
	{
178
		$this->controller->type( $types );
0 ignored issues
show
Bug introduced by
The method type cannot be called on $this->controller (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
179
		return $this;
180
	}
181
182
183
	/**
184
	 * Returns the frontend controller
185
	 *
186
	 * @return \Aimeos\Controller\Frontend\Stock\Iface Frontend controller object
187
	 */
188
	protected function getController()
189
	{
190
		return $this->controller;
191
	}
192
}
193