Completed
Branch master (f15584)
by Aimeos
10:05
created
client/jsonapi/src/Client/JsonApi/Stock/Factory.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 * @return \Aimeos\Client\JsonApi\Iface JSON API client
32 32
 	 * @throws \Aimeos\Client\JsonApi\Exception If requested client implementation couldn't be found or initialisation fails
33 33
 	 */
34
-	public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null )
34
+	public static function createClient(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null)
35 35
 	{
36
-		if( ctype_alnum( $path ) === false )
36
+		if (ctype_alnum($path) === false)
37 37
 		{
38
-			$path = ( is_string( $path ) ? $path : '<not a string>' );
39
-			throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid client "%1$s"', $path ), 400 );
38
+			$path = (is_string($path) ? $path : '<not a string>');
39
+			throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid client "%1$s"', $path), 400);
40 40
 		}
41 41
 
42 42
 		/** client/jsonapi/stock/name
@@ -72,23 +72,23 @@  discard block
 block discarded – undo
72 72
 		 * @since 2017.03
73 73
 		 * @category Developer
74 74
 		 */
75
-		if( $name === null ) {
76
-			$name = $context->getConfig()->get( 'client/jsonapi/stock/name', 'Standard' );
75
+		if ($name === null) {
76
+			$name = $context->getConfig()->get('client/jsonapi/stock/name', 'Standard');
77 77
 		}
78 78
 
79
-		if( ctype_alnum( $name ) === false )
79
+		if (ctype_alnum($name) === false)
80 80
 		{
81
-			$classname = is_string( $name ) ? '\\Aimeos\\Client\\JsonApi\\Stock\\' . $name : '<not a string>';
82
-			throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
81
+			$classname = is_string($name) ? '\\Aimeos\\Client\\JsonApi\\Stock\\' . $name : '<not a string>';
82
+			throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
83 83
 		}
84 84
 
85 85
 		$view = $context->getView();
86 86
 		$iface = '\\Aimeos\\Client\\JsonApi\\Iface';
87 87
 		$classname = '\\Aimeos\\Client\\JsonApi\\Stock\\' . $name;
88 88
 
89
-		$client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path );
89
+		$client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path);
90 90
 
91
-		return self::addClientDecorators( $client, $context, $view, $templatePaths, $path );
91
+		return self::addClientDecorators($client, $context, $view, $templatePaths, $path);
92 92
 	}
93 93
 
94 94
 }
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Product/Standard.php 2 patches
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -31,40 +31,40 @@  discard block
 block discarded – undo
31 31
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
32 32
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
33 33
 	 */
34
-	public function get( ServerRequestInterface $request, ResponseInterface $response )
34
+	public function get(ServerRequestInterface $request, ResponseInterface $response)
35 35
 	{
36 36
 		$view = $this->getView();
37 37
 
38 38
 		try
39 39
 		{
40
-			if( $view->param( 'aggregate' ) != '' ) {
41
-				$response = $this->aggregate( $view, $request, $response );
42
-			} elseif( $view->param( 'id' ) != '' ) {
43
-				$response = $this->getItem( $view, $request, $response );
40
+			if ($view->param('aggregate') != '') {
41
+				$response = $this->aggregate($view, $request, $response);
42
+			} elseif ($view->param('id') != '') {
43
+				$response = $this->getItem($view, $request, $response);
44 44
 			} else {
45
-				$response = $this->getItems( $view, $request, $response );
45
+				$response = $this->getItems($view, $request, $response);
46 46
 			}
47 47
 
48 48
 			$status = 200;
49 49
 		}
50
-		catch( \Aimeos\MShop\Exception $e )
50
+		catch (\Aimeos\MShop\Exception $e)
51 51
 		{
52 52
 			$status = 404;
53
-			$view->errors = array( array(
54
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
53
+			$view->errors = array(array(
54
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
55 55
 				'detail' => $e->getTraceAsString(),
56
-			) );
56
+			));
57 57
 		}
58
-		catch( \Exception $e )
58
+		catch (\Exception $e)
59 59
 		{
60 60
 			$status = 500;
61
-			$view->errors = array( array(
61
+			$view->errors = array(array(
62 62
 				'title' => $e->getMessage(),
63 63
 				'detail' => $e->getTraceAsString(),
64
-			) );
64
+			));
65 65
 		}
66 66
 
67
-		if( $view->param( 'aggregate' ) != '' )
67
+		if ($view->param('aggregate') != '')
68 68
 		{
69 69
 			/** client/jsonapi/product/standard/template-aggregate
70 70
 			 * Relative path to the product aggregate JSON API template
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 			$default = 'product/get-default.php';
114 114
 		}
115 115
 
116
-		$body = $view->render( $view->config( $tplconf, $default ) );
116
+		$body = $view->render($view->config($tplconf, $default));
117 117
 
118
-		return $response->withHeader( 'Allow', 'GET' )
119
-			->withHeader( 'Content-Type', 'application/vnd.api+json' )
120
-			->withBody( $view->response()->createStreamFromString( $body ) )
121
-			->withStatus( $status );
118
+		return $response->withHeader('Allow', 'GET')
119
+			->withHeader('Content-Type', 'application/vnd.api+json')
120
+			->withBody($view->response()->createStreamFromString($body))
121
+			->withStatus($status);
122 122
 	}
123 123
 
124 124
 
@@ -130,16 +130,16 @@  discard block
 block discarded – undo
130 130
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
131 131
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
132 132
 	 */
133
-	protected function aggregate( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
133
+	protected function aggregate(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
134 134
 	{
135
-		$key = $view->param( 'aggregate' );
136
-		$size = $view->param( 'page/limit', 10000 );
137
-		$start = $view->param( 'page/offset', 0 );
135
+		$key = $view->param('aggregate');
136
+		$size = $view->param('page/limit', 10000);
137
+		$start = $view->param('page/offset', 0);
138 138
 
139
-		$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'product' );
140
-		$filter = $this->getFilter( $view, null, '+', $start, $size );
139
+		$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'product');
140
+		$filter = $this->getFilter($view, null, '+', $start, $size);
141 141
 
142
-		$view->data = $cntl->aggregate( $filter, $key );
142
+		$view->data = $cntl->aggregate($filter, $key);
143 143
 
144 144
 		return $response;
145 145
 	}
@@ -153,25 +153,25 @@  discard block
 block discarded – undo
153 153
 	 * @param string $domain Domain name of the items that should be returned
154 154
 	 * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as keys and attribute items as values
155 155
 	 */
156
-	protected function getDomainItems( array $productItems, array $ref, $domain )
156
+	protected function getDomainItems(array $productItems, array $ref, $domain)
157 157
 	{
158 158
 		$ids = array();
159 159
 
160
-		foreach( $productItems as $item ) {
161
-			$ids = array_merge( $ids, array_keys( $item->getRefItems( $domain ) ) );
160
+		foreach ($productItems as $item) {
161
+			$ids = array_merge($ids, array_keys($item->getRefItems($domain)));
162 162
 		}
163 163
 
164
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain );
164
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain);
165 165
 
166
-		$search = $manager->createSearch( true );
166
+		$search = $manager->createSearch(true);
167 167
 		$expr = array(
168
-			$search->compare( '==', $domain . '.id', $ids ),
168
+			$search->compare('==', $domain . '.id', $ids),
169 169
 			$search->getConditions(),
170 170
 		);
171
-		$search->setConditions( $search->combine( '&&', $expr ) );
172
-		$search->setSlice( 0, 0x7fffffff );
171
+		$search->setConditions($search->combine('&&', $expr));
172
+		$search->setSlice(0, 0x7fffffff);
173 173
 
174
-		return $manager->searchItems( $search, $ref );
174
+		return $manager->searchItems($search, $ref);
175 175
 	}
176 176
 
177 177
 
@@ -185,20 +185,20 @@  discard block
 block discarded – undo
185 185
 	 * @param integer $size Slize size
186 186
 	 * @return \Aimeos\MW\Criteria\Iface Initialize search filter
187 187
 	 */
188
-	protected function getFilter( \Aimeos\MW\View\Iface $view, $sort, $direction, $start, $size )
188
+	protected function getFilter(\Aimeos\MW\View\Iface $view, $sort, $direction, $start, $size)
189 189
 	{
190
-		$listtype = $view->param( 'filter/f_listtype', 'default' );
191
-		$attrIds = $view->param( 'filter/f_attrid', array() );
192
-		$optIds = $view->param( 'filter/f_optid', array() );
193
-		$oneIds = $view->param( 'filter/f_oneid', array() );
190
+		$listtype = $view->param('filter/f_listtype', 'default');
191
+		$attrIds = $view->param('filter/f_attrid', array());
192
+		$optIds = $view->param('filter/f_optid', array());
193
+		$oneIds = $view->param('filter/f_oneid', array());
194 194
 
195 195
 		$context = $this->getContext();
196
-		$cntl = \Aimeos\Controller\Frontend\Factory::createController( $context, 'product' );
196
+		$cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'product');
197 197
 
198
-		$filter = $cntl->createFilter( $sort, $direction, $start, $size, $listtype );
199
-		$filter = $cntl->addFilterAttribute( $filter, $attrIds, $optIds, $oneIds );
198
+		$filter = $cntl->createFilter($sort, $direction, $start, $size, $listtype);
199
+		$filter = $cntl->addFilterAttribute($filter, $attrIds, $optIds, $oneIds);
200 200
 
201
-		if( ( $catid = $view->param( 'filter/f_catid' ) ) !== null )
201
+		if (($catid = $view->param('filter/f_catid')) !== null)
202 202
 		{
203 203
 			$default = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE;
204 204
 
@@ -228,19 +228,19 @@  discard block
 block discarded – undo
228 228
 			 * @since 2017.03
229 229
 			 * @category Developer
230 230
 			 */
231
-			$level = $context->getConfig()->get( 'client/jsonapi/product/levels', $default );
231
+			$level = $context->getConfig()->get('client/jsonapi/product/levels', $default);
232 232
 
233
-			$filter = $cntl->addFilterCategory( $filter, $catid, $level, $sort, $direction, $listtype );
233
+			$filter = $cntl->addFilterCategory($filter, $catid, $level, $sort, $direction, $listtype);
234 234
 		}
235 235
 
236
-		if( ( $search = $view->param( 'filter/f_search' ) ) !== null ) {
237
-			$filter = $cntl->addFilterText( $filter, $search, $sort, $direction, $listtype );
236
+		if (($search = $view->param('filter/f_search')) !== null) {
237
+			$filter = $cntl->addFilterText($filter, $search, $sort, $direction, $listtype);
238 238
 		}
239 239
 
240
-		$params = $view->param( 'filter', [] );
241
-		unset( $params['f_attrid'], $params['f_optid'], $params['f_oneid'] );
242
-		unset( $params['f_listtype'], $params['f_catid'], $params['f_search'] );
243
-		$filter = $this->initCriteriaConditions( $filter, ['filter' => $params] );
240
+		$params = $view->param('filter', []);
241
+		unset($params['f_attrid'], $params['f_optid'], $params['f_oneid']);
242
+		unset($params['f_listtype'], $params['f_catid'], $params['f_search']);
243
+		$filter = $this->initCriteriaConditions($filter, ['filter' => $params]);
244 244
 
245 245
 		return $filter;
246 246
 	}
@@ -254,28 +254,28 @@  discard block
 block discarded – undo
254 254
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
255 255
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
256 256
 	 */
257
-	protected function getItem( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
257
+	protected function getItem(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
258 258
 	{
259 259
 		$map = array();
260
-		$ref = $view->param( 'include', array() );
260
+		$ref = $view->param('include', array());
261 261
 
262
-		if( is_string( $ref ) ) {
263
-			$ref = explode( ',', $ref );
262
+		if (is_string($ref)) {
263
+			$ref = explode(',', $ref);
264 264
 		}
265 265
 
266
-		$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'product' );
266
+		$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'product');
267 267
 
268
-		$view->items = $cntl->getItem( $view->param( 'id' ), $ref );
268
+		$view->items = $cntl->getItem($view->param('id'), $ref);
269 269
 		$view->total = 1;
270 270
 
271
-		if( in_array( 'product', $ref, true ) ) {
272
-			$map['product'] = $this->getDomainItems( array( $view->items ), $ref, 'product' );
271
+		if (in_array('product', $ref, true)) {
272
+			$map['product'] = $this->getDomainItems(array($view->items), $ref, 'product');
273 273
 		}
274 274
 
275
-		if( in_array( 'attribute', $ref, true ) )
275
+		if (in_array('attribute', $ref, true))
276 276
 		{
277
-			$productItems = ( isset( $map['product'] ) ? array_merge( array( $view->items ), $map['product'] ) : array() );
278
-			$map['attribute'] = $this->getDomainItems( $productItems, $ref, 'attribute' );
277
+			$productItems = (isset($map['product']) ? array_merge(array($view->items), $map['product']) : array());
278
+			$map['attribute'] = $this->getDomainItems($productItems, $ref, 'attribute');
279 279
 		}
280 280
 
281 281
 		$view->itemMap = $map;
@@ -292,41 +292,41 @@  discard block
 block discarded – undo
292 292
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
293 293
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
294 294
 	 */
295
-	protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
295
+	protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
296 296
 	{
297 297
 		$total = 0;
298 298
 		$map = array();
299
-		$direction  = '+';
299
+		$direction = '+';
300 300
 
301
-		$ref = $view->param( 'include', array() );
302
-		$size = $view->param( 'page/limit', 48 );
303
-		$start = $view->param( 'page/offset', 0 );
304
-		$sort = $view->param( 'sort', 'relevance' );
301
+		$ref = $view->param('include', array());
302
+		$size = $view->param('page/limit', 48);
303
+		$start = $view->param('page/offset', 0);
304
+		$sort = $view->param('sort', 'relevance');
305 305
 
306
-		if( is_string( $ref ) ) {
307
-			$ref = explode( ',', $ref );
306
+		if (is_string($ref)) {
307
+			$ref = explode(',', $ref);
308 308
 		}
309 309
 
310
-		if( $sort[0] === '-' )
310
+		if ($sort[0] === '-')
311 311
 		{
312
-			$sort = substr( $sort, 1 );
312
+			$sort = substr($sort, 1);
313 313
 			$direction = '-';
314 314
 		}
315 315
 
316
-		$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'product' );
317
-		$filter = $this->getFilter( $view, $sort, $direction, $start, $size );
316
+		$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'product');
317
+		$filter = $this->getFilter($view, $sort, $direction, $start, $size);
318 318
 
319
-		$view->items = $cntl->searchItems( $filter, $ref, $total );
319
+		$view->items = $cntl->searchItems($filter, $ref, $total);
320 320
 		$view->total = $total;
321 321
 
322
-		if( in_array( 'product', $ref, true ) ) {
323
-			$map['product'] = $this->getDomainItems( $view->items, $ref, 'product' );
322
+		if (in_array('product', $ref, true)) {
323
+			$map['product'] = $this->getDomainItems($view->items, $ref, 'product');
324 324
 		}
325 325
 
326
-		if( in_array( 'attribute', $ref, true ) )
326
+		if (in_array('attribute', $ref, true))
327 327
 		{
328
-			$productItems = ( isset( $map['product'] ) ? array_merge( $view->items, $map['product'] ) : array() );
329
-			$map['attribute'] = $this->getDomainItems( $productItems, $ref, 'attribute' );
328
+			$productItems = (isset($map['product']) ? array_merge($view->items, $map['product']) : array());
329
+			$map['attribute'] = $this->getDomainItems($productItems, $ref, 'attribute');
330 330
 		}
331 331
 
332 332
 		$view->itemMap = $map;
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,16 +46,14 @@  discard block
 block discarded – undo
46 46
 			}
47 47
 
48 48
 			$status = 200;
49
-		}
50
-		catch( \Aimeos\MShop\Exception $e )
49
+		} catch( \Aimeos\MShop\Exception $e )
51 50
 		{
52 51
 			$status = 404;
53 52
 			$view->errors = array( array(
54 53
 				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
55 54
 				'detail' => $e->getTraceAsString(),
56 55
 			) );
57
-		}
58
-		catch( \Exception $e )
56
+		} catch( \Exception $e )
59 57
 		{
60 58
 			$status = 500;
61 59
 			$view->errors = array( array(
@@ -87,8 +85,7 @@  discard block
 block discarded – undo
87 85
 			 */
88 86
 			$tplconf = 'client/jsonapi/product/standard/template-aggregate';
89 87
 			$default = 'aggregate-default.php';
90
-		}
91
-		else
88
+		} else
92 89
 		{
93 90
 			/** client/jsonapi/product/standard/template-get
94 91
 			 * Relative path to the product JSON API template for GET requests
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Product/Factory.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 * @return \Aimeos\Client\JsonApi\Iface JSON API client
32 32
 	 * @throws \Aimeos\Client\JsonApi\Exception If requested client implementation couldn't be found or initialisation fails
33 33
 	 */
34
-	public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null )
34
+	public static function createClient(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null)
35 35
 	{
36
-		if( ctype_alnum( $path ) === false )
36
+		if (ctype_alnum($path) === false)
37 37
 		{
38
-			$path = ( is_string( $path ) ? $path : '<not a string>' );
39
-			throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid client "%1$s"', $path ), 400 );
38
+			$path = (is_string($path) ? $path : '<not a string>');
39
+			throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid client "%1$s"', $path), 400);
40 40
 		}
41 41
 
42 42
 		/** client/jsonapi/product/name
@@ -72,23 +72,23 @@  discard block
 block discarded – undo
72 72
 		 * @since 2017.03
73 73
 		 * @category Developer
74 74
 		 */
75
-		if( $name === null ) {
76
-			$name = $context->getConfig()->get( 'client/jsonapi/product/name', 'Standard' );
75
+		if ($name === null) {
76
+			$name = $context->getConfig()->get('client/jsonapi/product/name', 'Standard');
77 77
 		}
78 78
 
79
-		if( ctype_alnum( $name ) === false )
79
+		if (ctype_alnum($name) === false)
80 80
 		{
81
-			$classname = is_string( $name ) ? '\\Aimeos\\Client\\JsonApi\\Product\\' . $name : '<not a string>';
82
-			throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
81
+			$classname = is_string($name) ? '\\Aimeos\\Client\\JsonApi\\Product\\' . $name : '<not a string>';
82
+			throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
83 83
 		}
84 84
 
85 85
 		$view = $context->getView();
86 86
 		$iface = '\\Aimeos\\Client\\JsonApi\\Iface';
87 87
 		$classname = '\\Aimeos\\Client\\JsonApi\\Product\\' . $name;
88 88
 
89
-		$client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path );
89
+		$client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path);
90 90
 
91
-		return self::addClientDecorators( $client, $context, $view, $templatePaths, $path );
91
+		return self::addClientDecorators($client, $context, $view, $templatePaths, $path);
92 92
 	}
93 93
 
94 94
 }
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Standard.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @param string|null $prefix Form parameter prefix when nesting parameters is required
33 33
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
34 34
 	 */
35
-	public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null )
35
+	public function options(ServerRequestInterface $request, ResponseInterface $response, $prefix = null)
36 36
 	{
37 37
 		$view = $this->getView();
38 38
 
@@ -55,19 +55,19 @@  discard block
 block discarded – undo
55 55
 			 * @category Developer
56 56
 			 */
57 57
 			$default = ['attribute', 'catalog', 'product', 'stock'];
58
-			$resources = $this->getContext()->getConfig()->get( 'client/jsonapi/resources', $default );
58
+			$resources = $this->getContext()->getConfig()->get('client/jsonapi/resources', $default);
59 59
 
60 60
 			$view->resources = (array) $resources;
61 61
 			$view->prefix = $prefix;
62 62
 			$status = 200;
63 63
 		}
64
-		catch( \Exception $e )
64
+		catch (\Exception $e)
65 65
 		{
66 66
 			$status = 500;
67
-			$view->errors = array( array(
67
+			$view->errors = array(array(
68 68
 				'title' => $e->getMessage(),
69 69
 				'detail' => $e->getTraceAsString(),
70
-			) );
70
+			));
71 71
 		}
72 72
 
73 73
 		/** client/jsonapi/standard/template-options
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 		$tplconf = 'client/jsonapi/standard/template-options';
98 98
 		$default = 'options-default.php';
99 99
 
100
-		$body = $view->render( $view->config( $tplconf, $default ) );
100
+		$body = $view->render($view->config($tplconf, $default));
101 101
 
102
-		return $response->withHeader( 'Allow', 'GET' )
103
-			->withHeader( 'Content-Type', 'application/vnd.api+json' )
104
-			->withBody( $view->response()->createStreamFromString( $body ) )
105
-			->withStatus( $status );
102
+		return $response->withHeader('Allow', 'GET')
103
+			->withHeader('Content-Type', 'application/vnd.api+json')
104
+			->withBody($view->response()->createStreamFromString($body))
105
+			->withStatus($status);
106 106
 	}
107 107
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,8 +60,7 @@
 block discarded – undo
60 60
 			$view->resources = (array) $resources;
61 61
 			$view->prefix = $prefix;
62 62
 			$status = 200;
63
-		}
64
-		catch( \Exception $e )
63
+		} catch( \Exception $e )
65 64
 		{
66 65
 			$status = 500;
67 66
 			$view->errors = array( array(
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Iface.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
30 30
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
31 31
 	 */
32
-	public function delete( ServerRequestInterface $request, ResponseInterface $response );
32
+	public function delete(ServerRequestInterface $request, ResponseInterface $response);
33 33
 
34 34
 
35 35
 	/**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
40 40
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
41 41
 	 */
42
-	public function get( ServerRequestInterface $request, ResponseInterface $response );
42
+	public function get(ServerRequestInterface $request, ResponseInterface $response);
43 43
 
44 44
 
45 45
 	/**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
50 50
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
51 51
 	 */
52
-	public function patch( ServerRequestInterface $request, ResponseInterface $response );
52
+	public function patch(ServerRequestInterface $request, ResponseInterface $response);
53 53
 
54 54
 
55 55
 	/**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
60 60
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
61 61
 	 */
62
-	public function post( ServerRequestInterface $request, ResponseInterface $response );
62
+	public function post(ServerRequestInterface $request, ResponseInterface $response);
63 63
 
64 64
 
65 65
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
70 70
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
71 71
 	 */
72
-	public function put( ServerRequestInterface $request, ResponseInterface $response );
72
+	public function put(ServerRequestInterface $request, ResponseInterface $response);
73 73
 
74 74
 
75 75
 	/**
@@ -80,5 +80,5 @@  discard block
 block discarded – undo
80 80
 	 * @param string|null $prefix Form parameter prefix when nesting parameters is required
81 81
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
82 82
 	 */
83
-	public function options( ServerRequestInterface $request, ResponseInterface $response, $prefix = null );
83
+	public function options(ServerRequestInterface $request, ResponseInterface $response, $prefix = null);
84 84
 }
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Factory.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 	 * @param integer $id Context ID the objects have been created with (string of \Aimeos\MShop\Context\Item\Iface)
34 34
 	 * @param string $path Path describing the client to clear, e.g. "product/lists/type"
35 35
 	 */
36
-	static public function clear( $id = null, $path = null )
36
+	static public function clear($id = null, $path = null)
37 37
 	{
38
-		if( $id !== null )
38
+		if ($id !== null)
39 39
 		{
40
-			if( $path !== null ) {
40
+			if ($path !== null) {
41 41
 				self::$clients[$id][$path] = null;
42 42
 			} else {
43 43
 				self::$clients[$id] = array();
@@ -65,19 +65,19 @@  discard block
 block discarded – undo
65 65
 	 * @return \Aimeos\Client\JsonApi\Iface JSON client instance
66 66
 	 * @throws \Aimeos\Client\JsonApi\Exception If the given path is invalid
67 67
 	 */
68
-	static public function createClient( \Aimeos\MShop\Context\Item\Iface $context,
69
-		array $templatePaths, $path, $name = null )
68
+	static public function createClient(\Aimeos\MShop\Context\Item\Iface $context,
69
+		array $templatePaths, $path, $name = null)
70 70
 	{
71
-		$path = strtolower( trim( $path, "/ \n\t\r\0\x0B" ) );
71
+		$path = strtolower(trim($path, "/ \n\t\r\0\x0B"));
72 72
 
73
-		if( empty( $path ) ) {
74
-			return self::createClientRoot( $context, $context->getView(), $templatePaths, $path, $name );
73
+		if (empty($path)) {
74
+			return self::createClientRoot($context, $context->getView(), $templatePaths, $path, $name);
75 75
 		}
76 76
 
77 77
 		$id = (string) $context;
78 78
 
79
-		if( self::$cache === false || !isset( self::$clients[$id][$path] ) ) {
80
-			self::$clients[$id][$path] = self::createClientNew( $context, $templatePaths, $path, $name );
79
+		if (self::$cache === false || !isset(self::$clients[$id][$path])) {
80
+			self::$clients[$id][$path] = self::createClientNew($context, $templatePaths, $path, $name);
81 81
 		}
82 82
 
83 83
 		return self::$clients[$id][$path];
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param boolean $value True to enable caching, false to disable it.
91 91
 	 * @return boolean Previous cache setting
92 92
 	 */
93
-	static public function setCache( $value )
93
+	static public function setCache($value)
94 94
 	{
95 95
 		$old = self::$cache;
96 96
 		self::$cache = (boolean) $value;
@@ -109,37 +109,37 @@  discard block
 block discarded – undo
109 109
 	 * @return \Aimeos\Client\JsonApi\Iface JSON client instance
110 110
 	 * @throws \Aimeos\Client\JsonApi\Exception If the given path is invalid
111 111
 	 */
112
-	protected static function createClientNew( \Aimeos\MShop\Context\Item\Iface $context,
113
-		array $templatePaths, $path, $name )
112
+	protected static function createClientNew(\Aimeos\MShop\Context\Item\Iface $context,
113
+		array $templatePaths, $path, $name)
114 114
 	{
115
-		$parts = explode( '/', $path );
115
+		$parts = explode('/', $path);
116 116
 
117
-		foreach( $parts as $key => $part )
117
+		foreach ($parts as $key => $part)
118 118
 		{
119
-			if( ctype_alnum( $part ) === false )
119
+			if (ctype_alnum($part) === false)
120 120
 			{
121
-				$msg = sprintf( 'Invalid client "%1$s" in "%2$s"', $part, $path );
122
-				throw new \Aimeos\Client\JsonApi\Exception( $msg, 400 );
121
+				$msg = sprintf('Invalid client "%1$s" in "%2$s"', $part, $path);
122
+				throw new \Aimeos\Client\JsonApi\Exception($msg, 400);
123 123
 			}
124 124
 
125
-			$parts[$key] = ucwords( $part );
125
+			$parts[$key] = ucwords($part);
126 126
 		}
127 127
 
128 128
 
129 129
 		$view = $context->getView();
130
-		$factory = '\\Aimeos\\Client\\JsonApi\\' . join( '\\', $parts ) . '\\Factory';
130
+		$factory = '\\Aimeos\\Client\\JsonApi\\' . join('\\', $parts) . '\\Factory';
131 131
 
132
-		if( class_exists( $factory ) === true )
132
+		if (class_exists($factory) === true)
133 133
 		{
134
-			$args = array( $context, $templatePaths, $path, $name );
134
+			$args = array($context, $templatePaths, $path, $name);
135 135
 
136
-			if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) {
137
-				throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 );
136
+			if (($client = @call_user_func_array(array($factory, 'createClient'), $args)) === false) {
137
+				throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid factory "%1$s"', $factory), 400);
138 138
 			}
139 139
 		}
140 140
 		else
141 141
 		{
142
-			$client = self::createClientRoot( $context, $view, $templatePaths, $path, $name );
142
+			$client = self::createClientRoot($context, $view, $templatePaths, $path, $name);
143 143
 		}
144 144
 
145 145
 		return $client;
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 	 * @return \Aimeos\Client\JsonApi\Iface JSON client instance
158 158
 	 * @throws \Aimeos\Client\JsonApi\Exception If the client couldn't be created
159 159
 	 */
160
-	protected static function createClientRoot( \Aimeos\MShop\Context\Item\Iface $context,
161
-		\Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null )
160
+	protected static function createClientRoot(\Aimeos\MShop\Context\Item\Iface $context,
161
+		\Aimeos\MW\View\Iface $view, array $templatePaths, $path, $name = null)
162 162
 	{
163 163
 		/** client/jsonapi/name
164 164
 		 * Class name of the used JSON API client implementation
@@ -193,20 +193,20 @@  discard block
 block discarded – undo
193 193
 		 * @since 2015.12
194 194
 		 * @category Developer
195 195
 		 */
196
-		if( $name === null ) {
197
-			$name = $context->getConfig()->get( 'client/jsonapi/name', 'Standard' );
196
+		if ($name === null) {
197
+			$name = $context->getConfig()->get('client/jsonapi/name', 'Standard');
198 198
 		}
199 199
 
200
-		if( ctype_alnum( $name ) === false )
200
+		if (ctype_alnum($name) === false)
201 201
 		{
202
-			$classname = is_string( $name ) ? '\\Aimeos\\Client\\JsonApi\\' . $name : '<not a string>';
203
-			throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid class name "%1$s"', $classname ) );
202
+			$classname = is_string($name) ? '\\Aimeos\\Client\\JsonApi\\' . $name : '<not a string>';
203
+			throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid class name "%1$s"', $classname));
204 204
 		}
205 205
 
206 206
 		$iface = '\\Aimeos\\Client\\JsonApi\\Iface';
207 207
 		$classname = '\\Aimeos\\Client\\JsonApi\\' . $name;
208 208
 
209
-		$client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path );
209
+		$client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path);
210 210
 
211 211
 		/** client/jsonapi/decorators/excludes
212 212
 		 * Excludes decorators added by the "common" option from the JSON API clients
@@ -286,6 +286,6 @@  discard block
 block discarded – undo
286 286
 		 * @see client/jsonapi/decorators/global
287 287
 		 */
288 288
 
289
-		return self::addClientDecorators( $client, $context, $view, $templatePaths, $path );
289
+		return self::addClientDecorators($client, $context, $view, $templatePaths, $path);
290 290
 	}
291 291
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -136,8 +136,7 @@
 block discarded – undo
136 136
 			if( ( $client = @call_user_func_array( array( $factory, 'createClient' ), $args ) ) === false ) {
137 137
 				throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid factory "%1$s"', $factory ), 400 );
138 138
 			}
139
-		}
140
-		else
139
+		} else
141 140
 		{
142 141
 			$client = self::createClientRoot( $context, $view, $templatePaths, $path, $name );
143 142
 		}
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Attribute/Standard.php 2 patches
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -31,35 +31,35 @@  discard block
 block discarded – undo
31 31
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
32 32
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
33 33
 	 */
34
-	public function get( ServerRequestInterface $request, ResponseInterface $response )
34
+	public function get(ServerRequestInterface $request, ResponseInterface $response)
35 35
 	{
36 36
 		$view = $this->getView();
37 37
 
38 38
 		try
39 39
 		{
40
-			if( $view->param( 'id' ) != '' ) {
41
-				$response = $this->getItem( $view, $request, $response );
40
+			if ($view->param('id') != '') {
41
+				$response = $this->getItem($view, $request, $response);
42 42
 			} else {
43
-				$response = $this->getItems( $view, $request, $response );
43
+				$response = $this->getItems($view, $request, $response);
44 44
 			}
45 45
 
46 46
 			$status = 200;
47 47
 		}
48
-		catch( \Aimeos\MShop\Exception $e )
48
+		catch (\Aimeos\MShop\Exception $e)
49 49
 		{
50 50
 			$status = 404;
51
-			$view->errors = array( array(
52
-				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
51
+			$view->errors = array(array(
52
+				'title' => $this->getContext()->getI18n()->dt('mshop', $e->getMessage()),
53 53
 				'detail' => $e->getTraceAsString(),
54
-			) );
54
+			));
55 55
 		}
56
-		catch( \Exception $e )
56
+		catch (\Exception $e)
57 57
 		{
58 58
 			$status = 500;
59
-			$view->errors = array( array(
59
+			$view->errors = array(array(
60 60
 				'title' => $e->getMessage(),
61 61
 				'detail' => $e->getTraceAsString(),
62
-			) );
62
+			));
63 63
 		}
64 64
 
65 65
 		/** client/jsonapi/attribute/standard/template-get
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
 		$tplconf = 'client/jsonapi/attribute/standard/template-get';
85 85
 		$default = 'attribute/get-default.php';
86 86
 
87
-		$body = $view->render( $view->config( $tplconf, $default ) );
87
+		$body = $view->render($view->config($tplconf, $default));
88 88
 
89
-		return $response->withHeader( 'Allow', 'GET' )
90
-			->withHeader( 'Content-Type', 'application/vnd.api+json' )
91
-			->withBody( $view->response()->createStreamFromString( $body ) )
92
-			->withStatus( $status );
89
+		return $response->withHeader('Allow', 'GET')
90
+			->withHeader('Content-Type', 'application/vnd.api+json')
91
+			->withBody($view->response()->createStreamFromString($body))
92
+			->withStatus($status);
93 93
 	}
94 94
 
95 95
 
@@ -101,17 +101,17 @@  discard block
 block discarded – undo
101 101
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
102 102
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
103 103
 	 */
104
-	protected function getItem( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
104
+	protected function getItem(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
105 105
 	{
106
-		$ref = $view->param( 'include', array() );
106
+		$ref = $view->param('include', array());
107 107
 
108
-		if( is_string( $ref ) ) {
109
-			$ref = explode( ',', $ref );
108
+		if (is_string($ref)) {
109
+			$ref = explode(',', $ref);
110 110
 		}
111 111
 
112
-		$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'attribute' );
112
+		$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'attribute');
113 113
 
114
-		$view->items = $cntl->getItem( $view->param( 'id' ), $ref );
114
+		$view->items = $cntl->getItem($view->param('id'), $ref);
115 115
 		$view->total = 1;
116 116
 
117 117
 		return $response;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @param \Psr\Http\Message\ResponseInterface $response Response object
127 127
 	 * @return \Psr\Http\Message\ResponseInterface Modified response object
128 128
 	 */
129
-	protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response )
129
+	protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response)
130 130
 	{
131 131
 		/** client/jsonapi/attribute/types
132 132
 		 * List of attribute types that should be displayed in this order in the catalog filter
@@ -146,37 +146,37 @@  discard block
 block discarded – undo
146 146
 		 * @since 2017.03
147 147
 		 * @category Developer
148 148
 		 */
149
-		$attrTypes = $this->getContext()->getConfig()->get( 'client/jsonapi/attribute/types', array() );
149
+		$attrTypes = $this->getContext()->getConfig()->get('client/jsonapi/attribute/types', array());
150 150
 
151 151
 		$total = 0;
152 152
 		$attrMap = [];
153 153
 
154
-		$ref = $view->param( 'include', array() );
154
+		$ref = $view->param('include', array());
155 155
 
156
-		if( is_string( $ref ) ) {
157
-			$ref = explode( ',', $ref );
156
+		if (is_string($ref)) {
157
+			$ref = explode(',', $ref);
158 158
 		}
159 159
 
160
-		$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'attribute' );
160
+		$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'attribute');
161 161
 
162 162
 		$filter = $cntl->createFilter();
163
-		$filter = $this->initCriteriaConditions( $filter, $view->param() );
164
-		$filter = $cntl->addFilterTypes( $filter, $attrTypes );
163
+		$filter = $this->initCriteriaConditions($filter, $view->param());
164
+		$filter = $cntl->addFilterTypes($filter, $attrTypes);
165 165
 
166
-		$items = $cntl->searchItems( $filter, $ref, $total );
166
+		$items = $cntl->searchItems($filter, $ref, $total);
167 167
 
168
-		foreach( $items as $id => $item ) {
168
+		foreach ($items as $id => $item) {
169 169
 			$attrMap[$item->getType()][$id] = $item;
170 170
 		}
171 171
 
172
-		if( !empty( $attrTypes ) )
172
+		if (!empty($attrTypes))
173 173
 		{
174 174
 			$sorted = [];
175 175
 
176
-			foreach( $attrTypes as $type )
176
+			foreach ($attrTypes as $type)
177 177
 			{
178
-				if( isset( $attrMap[$type] ) ) {
179
-					$sorted = array_merge( $sorted, $attrMap[$type] );
178
+				if (isset($attrMap[$type])) {
179
+					$sorted = array_merge($sorted, $attrMap[$type]);
180 180
 				}
181 181
 			}
182 182
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,16 +44,14 @@
 block discarded – undo
44 44
 			}
45 45
 
46 46
 			$status = 200;
47
-		}
48
-		catch( \Aimeos\MShop\Exception $e )
47
+		} catch( \Aimeos\MShop\Exception $e )
49 48
 		{
50 49
 			$status = 404;
51 50
 			$view->errors = array( array(
52 51
 				'title' => $this->getContext()->getI18n()->dt( 'mshop', $e->getMessage() ),
53 52
 				'detail' => $e->getTraceAsString(),
54 53
 			) );
55
-		}
56
-		catch( \Exception $e )
54
+		} catch( \Exception $e )
57 55
 		{
58 56
 			$status = 500;
59 57
 			$view->errors = array( array(
Please login to merge, or discard this patch.
client/jsonapi/src/Client/JsonApi/Attribute/Factory.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 * @return \Aimeos\Client\JsonApi\Iface JSON API client
32 32
 	 * @throws \Aimeos\Client\JsonApi\Exception If requested client implementation couldn't be found or initialisation fails
33 33
 	 */
34
-	public static function createClient( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null )
34
+	public static function createClient(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $path, $name = null)
35 35
 	{
36
-		if( ctype_alnum( $path ) === false )
36
+		if (ctype_alnum($path) === false)
37 37
 		{
38
-			$path = ( is_string( $path ) ? $path : '<not a string>' );
39
-			throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid client "%1$s"', $path ), 400 );
38
+			$path = (is_string($path) ? $path : '<not a string>');
39
+			throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid client "%1$s"', $path), 400);
40 40
 		}
41 41
 
42 42
 		/** client/jsonapi/attribute/name
@@ -72,23 +72,23 @@  discard block
 block discarded – undo
72 72
 		 * @since 2017.03
73 73
 		 * @category Developer
74 74
 		 */
75
-		if( $name === null ) {
76
-			$name = $context->getConfig()->get( 'client/jsonapi/attribute/name', 'Standard' );
75
+		if ($name === null) {
76
+			$name = $context->getConfig()->get('client/jsonapi/attribute/name', 'Standard');
77 77
 		}
78 78
 
79
-		if( ctype_alnum( $name ) === false )
79
+		if (ctype_alnum($name) === false)
80 80
 		{
81
-			$classname = is_string( $name ) ? '\\Aimeos\\Client\\JsonApi\\Attribute\\' . $name : '<not a string>';
82
-			throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
81
+			$classname = is_string($name) ? '\\Aimeos\\Client\\JsonApi\\Attribute\\' . $name : '<not a string>';
82
+			throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
83 83
 		}
84 84
 
85 85
 		$view = $context->getView();
86 86
 		$iface = '\\Aimeos\\Client\\JsonApi\\Iface';
87 87
 		$classname = '\\Aimeos\\Client\\JsonApi\\Attribute\\' . $name;
88 88
 
89
-		$client = self::createClientBase( $classname, $iface, $context, $view, $templatePaths, $path );
89
+		$client = self::createClientBase($classname, $iface, $context, $view, $templatePaths, $path);
90 90
 
91
-		return self::addClientDecorators( $client, $context, $view, $templatePaths, $path );
91
+		return self::addClientDecorators($client, $context, $view, $templatePaths, $path);
92 92
 	}
93 93
 
94 94
 }
Please login to merge, or discard this patch.