Completed
Push — master ( 026233...c7df97 )
by Aimeos
02:33
created

Base::setAimeos()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2017
6
 * @package Admin
7
 * @subpackage JsonAdm
8
 */
9
10
11
namespace Aimeos\Admin\JsonAdm\Common\Decorator;
12
13
use Psr\Http\Message\ServerRequestInterface;
14
use Psr\Http\Message\ResponseInterface;
15
16
17
/**
18
 * Provides common methods for JSON API client decorators
19
 *
20
 * @package Admin
21
 * @subpackage JsonAdm
22
 */
23
abstract class Base
24
	extends \Aimeos\Admin\JsonAdm\Base
0 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...
25
	implements \Aimeos\Admin\JsonAdm\Common\Decorator\Iface
0 ignored issues
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
26
{
27
	private $client;
28
29
30
	/**
31
	 * Initializes the client decorator.
32
	 *
33
	 * @param \Aimeos\Admin\JsonAdm\Iface $client Client object
34
	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects
35
	 * @param string $path Name of the client separated by slashes, e.g "product/property"
36
	 */
37
	public function __construct( \Aimeos\Admin\JsonAdm\Iface $client, \Aimeos\MShop\Context\Item\Iface $context, $path )
38
	{
39
		parent::__construct( $context, $path );
40
41
		$this->client = $client;
42
	}
43
44
45
	/**
46
	 * Passes unknown methods to wrapped objects
47
	 *
48
	 * @param string $name Name of the method
49
	 * @param array $param List of method parameter
50
	 * @return mixed Returns the value of the called method
51
	 * @throws \Aimeos\Admin\JsonAdm\Exception If method call failed
52
	 */
53
	public function __call( $name, array $param )
54
	{
55
		return @call_user_func_array( array( $this->client, $name ), $param );
56
	}
57
58
59
	/**
60
	 * Deletes the resource or the resource list
61
	 *
62
	 * @param \Psr\Http\Message\ServerRequestInterface $request Request object
63
	 * @param \Psr\Http\Message\ResponseInterface $response Response object
64
	 * @return \Psr\Http\Message\ResponseInterface Modified response object
65
	 */
66
	public function delete( ServerRequestInterface $request, ResponseInterface $response )
67
	{
68
		return $this->client->delete( $request, $response );
69
	}
70
71
72
	/**
73
	 * Returns the requested resource or the resource list
74
	 *
75
	 * @param \Psr\Http\Message\ServerRequestInterface $request Request object
76
	 * @param \Psr\Http\Message\ResponseInterface $response Response object
77
	 * @return \Psr\Http\Message\ResponseInterface Modified response object
78
	 */
79
	public function get( ServerRequestInterface $request, ResponseInterface $response )
80
	{
81
		return $this->client->get( $request, $response );
82
	}
83
84
85
86
	/**
87
	 * Updates the resource or the resource list partitially
88
	 *
89
	 * @param \Psr\Http\Message\ServerRequestInterface $request Request object
90
	 * @param \Psr\Http\Message\ResponseInterface $response Response object
91
	 * @return \Psr\Http\Message\ResponseInterface Modified response object
92
	 */
93
	public function patch( ServerRequestInterface $request, ResponseInterface $response )
94
	{
95
		return $this->client->patch( $request, $response );
96
	}
97
98
99
100
	/**
101
	 * Creates or updates the resource or the resource list
102
	 *
103
	 * @param \Psr\Http\Message\ServerRequestInterface $request Request object
104
	 * @param \Psr\Http\Message\ResponseInterface $response Response object
105
	 * @return \Psr\Http\Message\ResponseInterface Modified response object
106
	 */
107
	public function post( ServerRequestInterface $request, ResponseInterface $response )
108
	{
109
		return $this->client->post( $request, $response );
110
	}
111
112
113
114
	/**
115
	 * Creates or updates the resource or the resource list
116
	 *
117
	 * @param \Psr\Http\Message\ServerRequestInterface $request Request object
118
	 * @param \Psr\Http\Message\ResponseInterface $response Response object
119
	 * @return \Psr\Http\Message\ResponseInterface Modified response object
120
	 */
121
	public function put( ServerRequestInterface $request, ResponseInterface $response )
122
	{
123
		return $this->client->put( $request, $response );
124
	}
125
126
127
128
	/**
129
	 * Returns the available REST verbs
130
	 *
131
	 * @param \Psr\Http\Message\ServerRequestInterface $request Request object
132
	 * @param \Psr\Http\Message\ResponseInterface $response Response object
133
	 * @param string|null $prefix Form parameter prefix when nesting parameters is required
134
	 * @return \Psr\Http\Message\ResponseInterface Modified response object
135
	 */
136
	public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null )
137
	{
138
		return $this->client->options( $request, $response, $prefix );
0 ignored issues
show
Unused Code introduced by
The call to Iface::options() has too many arguments starting with $prefix.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
139
	}
140
141
142
	/**
143
	 * Returns the Aimeos bootstrap object
144
	 *
145
	 * @return \Aimeos\Bootstrap The Aimeos bootstrap object
146
	 */
147
	public function getAimeos()
148
	{
149
		return $this->client->getAimeos();
150
	}
151
152
153
	/**
154
	 * Sets the Aimeos bootstrap object
155
	 *
156
	 * @param \Aimeos\Bootstrap $aimeos The Aimeos bootstrap object
157
	 * @return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls
158
	 */
159
	public function setAimeos( \Aimeos\Bootstrap $aimeos )
160
	{
161
		parent::setAimeos( $aimeos );
162
163
		$this->client->setAimeos( $aimeos );
164
		return $this;
165
	}
166
167
168
	/**
169
	 * Returns the view object that will generate the admin output.
170
	 *
171
	 * @return \Aimeos\MW\View\Iface The view object which generates the admin output
172
	 */
173
	public function getView()
174
	{
175
		return $this->client->getView();
176
	}
177
178
179
	/**
180
	 * Sets the view object that will generate the admin output.
181
	 *
182
	 * @param \Aimeos\MW\View\Iface $view The view object which generates the admin output
183
	 * @return \Aimeos\Admin\JQAdm\Iface Reference to this object for fluent calls
184
	 */
185
	public function setView( \Aimeos\MW\View\Iface $view )
186
	{
187
		parent::setView( $view );
188
189
		$this->client->setView( $view );
190
		return $this;
191
	}
192
193
194
	/**
195
	 * Returns the underlying admin client object;
196
	 *
197
	 * @return \Aimeos\Admin\JsonAdm\Iface Admin client object
198
	 */
199
	protected function getClient()
200
	{
201
		return $this->client;
202
	}
203
}
204