Passed
Push — master ( a14c92...413d3b )
by Aimeos
05:44 queued 03:20
created

Base::view()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2021
6
 * @package Client
7
 * @subpackage JsonApi
8
 */
9
10
11
namespace Aimeos\Client\JsonApi\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 Client
21
 * @subpackage JsonApi
22
 */
23
abstract class Base
24
	extends \Aimeos\Client\JsonApi\Base
25
	implements \Aimeos\Client\JsonApi\Common\Decorator\Iface
26
{
27
	private $client;
28
29
30
	/**
31
	 * Initializes the client decorator.
32
	 *
33
	 * @param \Aimeos\Client\JsonApi\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, e.g "product"
36
	 */
37
	public function __construct( \Aimeos\Client\JsonApi\Iface $client,
38
		\Aimeos\MShop\Context\Item\Iface $context, string $path )
39
	{
40
		parent::__construct( $context, $path );
41
42
		$this->client = $client;
43
	}
44
45
46
	/**
47
	 * Passes unknown methods to wrapped objects
48
	 *
49
	 * @param string $name Name of the method
50
	 * @param array $param List of method parameter
51
	 * @return mixed Returns the value of the called method
52
	 * @throws \Aimeos\Client\JsonApi\Exception If method call failed
53
	 */
54
	public function __call( string $name, array $param )
55
	{
56
		return @call_user_func_array( array( $this->client, $name ), $param );
57
	}
58
59
60
	/**
61
	 * Deletes the resource or the resource list
62
	 *
63
	 * @param \Psr\Http\Message\ServerRequestInterface $request Request object
64
	 * @param \Psr\Http\Message\ResponseInterface $response Response object
65
	 * @return \Psr\Http\Message\ResponseInterface Modified response object
66
	 */
67
	public function delete( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface
68
	{
69
		return $this->client->delete( $request, $response );
70
	}
71
72
73
	/**
74
	 * Returns the requested resource or the resource list
75
	 *
76
	 * @param \Psr\Http\Message\ServerRequestInterface $request Request object
77
	 * @param \Psr\Http\Message\ResponseInterface $response Response object
78
	 * @return \Psr\Http\Message\ResponseInterface Modified response object
79
	 */
80
	public function get( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface
81
	{
82
		return $this->client->get( $request, $response );
83
	}
84
85
86
87
	/**
88
	 * Updates the resource or the resource list partitially
89
	 *
90
	 * @param \Psr\Http\Message\ServerRequestInterface $request Request object
91
	 * @param \Psr\Http\Message\ResponseInterface $response Response object
92
	 * @return \Psr\Http\Message\ResponseInterface Modified response object
93
	 */
94
	public function patch( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface
95
	{
96
		return $this->client->patch( $request, $response );
97
	}
98
99
100
101
	/**
102
	 * Creates or updates the resource or the resource list
103
	 *
104
	 * @param \Psr\Http\Message\ServerRequestInterface $request Request object
105
	 * @param \Psr\Http\Message\ResponseInterface $response Response object
106
	 * @return \Psr\Http\Message\ResponseInterface Modified response object
107
	 */
108
	public function post( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface
109
	{
110
		return $this->client->post( $request, $response );
111
	}
112
113
114
115
	/**
116
	 * Creates or updates the resource or the resource list
117
	 *
118
	 * @param \Psr\Http\Message\ServerRequestInterface $request Request object
119
	 * @param \Psr\Http\Message\ResponseInterface $response Response object
120
	 * @return \Psr\Http\Message\ResponseInterface Modified response object
121
	 */
122
	public function put( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface
123
	{
124
		return $this->client->put( $request, $response );
125
	}
126
127
128
129
	/**
130
	 * Returns the available REST verbs
131
	 *
132
	 * @param \Psr\Http\Message\ServerRequestInterface $request Request object
133
	 * @param \Psr\Http\Message\ResponseInterface $response Response object
134
	 * @return \Psr\Http\Message\ResponseInterface Modified response object
135
	 */
136
	public function options( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface
137
	{
138
		return $this->client->options( $request, $response );
139
	}
140
141
142
	/**
143
	 * Sets the view object that will generate the admin output.
144
	 *
145
	 * @param \Aimeos\MW\View\Iface $view The view object which generates the admin output
146
	 * @return \Aimeos\Client\JsonApi\Iface Reference to this object for fluent calls
147
	 */
148
	public function setView( \Aimeos\MW\View\Iface $view ) : \Aimeos\Client\JsonApi\Iface
149
	{
150
		$this->client->setView( $view );
151
		parent::setView( $view );
152
153
		return $this;
154
	}
155
156
157
	/**
158
	 * Returns the underlying client object;
159
	 *
160
	 * @return \Aimeos\Client\JsonApi\Iface Client object
161
	 */
162
	protected function getClient() : \Aimeos\Client\JsonApi\Iface
163
	{
164
		return $this->client;
165
	}
166
}
167