Passed
Push — master ( a378fc...845eb3 )
by Aimeos
03:52
created

Standard::body()   B

Complexity

Conditions 6
Paths 19

Size

Total Lines 61
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 24
nc 19
nop 1
dl 0
loc 61
rs 8.9137
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2013
6
 * @copyright Aimeos (aimeos.org), 2015-2022
7
 * @package Client
8
 * @subpackage Html
9
 */
10
11
12
namespace Aimeos\Client\Html\Checkout\Update;
13
14
15
/**
16
 * Default implementation of update checkout HTML client.
17
 *
18
 * @package Client
19
 * @subpackage Html
20
 */
21
class Standard
22
	extends \Aimeos\Client\Html\Common\Client\Factory\Base
23
	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
24
{
25
	/**
26
	 * Processes the input, e.g. store given values.
27
	 *
28
	 * A view must be available and this method doesn't generate any output
29
	 * besides setting view variables.
30
	 */
31
	public function init()
32
	{
33
		$view = $this->view();
34
		$context = $this->context();
35
36
		try
37
		{
38
			$cntl = \Aimeos\Controller\Frontend::create( $context, 'service' );
39
			$cntl->updatePush( $view->request(), $view->response(), $view->param( 'code', '' ) );
40
		}
41
		catch( \Exception $e )
42
		{
43
			$view->response()->withStatus( 500, 'Error updating order status' );
44
			$view->response()->getBody()->write( $e->getMessage() );
45
46
			$body = (string) $view->request()->getBody();
47
			$str = "Updating order status failed: %1\$s\n%2\$s\n%3\$s";
48
			$msg = sprintf( $str, $e->getMessage(), print_r( $view->param(), true ), $body );
0 ignored issues
show
Bug introduced by
It seems like print_r($view->param(), true) can also be of type true; however, parameter $values of sprintf() does only seem to accept double|integer|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

48
			$msg = sprintf( $str, $e->getMessage(), /** @scrutinizer ignore-type */ print_r( $view->param(), true ), $body );
Loading history...
49
			$context->logger()->error( $msg, 'client/html' );
50
		}
51
	}
52
53
54
	/** client/html/checkout/update/template-body
55
	 * Relative path to the HTML body template of the checkout update client.
56
	 *
57
	 * The template file contains the HTML code and processing instructions
58
	 * to generate the result shown in the body of the frontend. The
59
	 * configuration string is the path to the template file relative
60
	 * to the templates directory (usually in client/html/templates).
61
	 *
62
	 * You can overwrite the template file configuration in extensions and
63
	 * provide alternative templates. These alternative templates should be
64
	 * named like the default one but suffixed by
65
	 * an unique name. You may use the name of your project for this. If
66
	 * you've implemented an alternative client class as well, it
67
	 * should be suffixed by the name of the new class.
68
	 *
69
	 * @param string Relative path to the template creating code for the HTML page body
70
	 * @since 2014.03
71
	 * @category Developer
72
	 * @see client/html/checkout/update/template-header
73
	 */
74
75
	/** client/html/checkout/update/template-header
76
	 * Relative path to the HTML header template of the checkout update client.
77
	 *
78
	 * The template file contains the HTML code and processing instructions
79
	 * to generate the HTML code that is inserted into the HTML page header
80
	 * of the rendered page in the frontend. The configuration string is the
81
	 * path to the template file relative to the templates directory (usually
82
	 * in client/html/templates).
83
	 *
84
	 * You can overwrite the template file configuration in extensions and
85
	 * provide alternative templates. These alternative templates should be
86
	 * named like the default one but suffixed by
87
	 * an unique name. You may use the name of your project for this. If
88
	 * you've implemented an alternative client class as well, it
89
	 * should be suffixed by the name of the new class.
90
	 *
91
	 * @param string Relative path to the template creating code for the HTML page head
92
	 * @since 2014.03
93
	 * @category Developer
94
	 * @see client/html/checkout/update/template-body
95
	 */
96
}
97