Passed
Push — master ( 6cd0a8...5d904d )
by Aimeos
03:19
created

Standard::getSubClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 74
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 74
rs 10
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 Aimeos (aimeos.org), 2015-2022
6
 * @package Client
7
 * @subpackage Html
8
 */
9
10
11
namespace Aimeos\Client\Html\Locale\Select\Currency;
12
13
14
/**
15
 * Default implementation of acount select currency HTML client.
16
 *
17
 * @package Client
18
 * @subpackage Html
19
 */
20
class Standard
21
	extends \Aimeos\Client\Html\Common\Client\Factory\Base
22
	implements \Aimeos\Client\Html\Common\Client\Factory\Iface
23
{
24
	/**
25
	 * Returns the HTML code for insertion into the body.
26
	 *
27
	 * @param string $uid Unique identifier for the output if the content is placed more than once on the same page
28
	 * @return string HTML code
29
	 */
30
	public function body( string $uid = '' ) : string
31
	{
32
		$view = $this->view();
33
34
		/** client/html/locale/select/currency/template-body
35
		 * Relative path to the HTML body template of the locale select currency client.
36
		 *
37
		 * The template file contains the HTML code and processing instructions
38
		 * to generate the result shown in the body of the frontend. The
39
		 * configuration string is the path to the template file relative
40
		 * to the templates directory (usually in client/html/templates).
41
		 *
42
		 * You can overwrite the template file configuration in extensions and
43
		 * provide alternative templates. These alternative templates should be
44
		 * named like the default one but suffixed by
45
		 * an unique name. You may use the name of your project for this. If
46
		 * you've implemented an alternative client class as well, it
47
		 * should be suffixed by the name of the new class.
48
		 *
49
		 * @param string Relative path to the template creating code for the HTML page body
50
		 * @since 2014.09
51
		 * @see client/html/locale/select/currency/template-header
52
		 */
53
		$tplconf = 'client/html/locale/select/currency/template-body';
54
		$default = 'locale/select/currency-body';
55
56
		return $view->render( $view->config( $tplconf, $default ) );
57
	}
58
59
60
	/**
61
	 * Processes the input, e.g. store given values.
62
	 *
63
	 * A view must be available and this method doesn't generate any output
64
	 * besides setting view variables.
65
	 */
66
	public function init()
67
	{
68
		$context = $this->context();
69
		$name = $context->config()->get( 'client/html/locale/select/currency/param-name', 'currency' );
70
71
		if( $currencyId = $this->view()->param( $name ) ) {
72
			$context->session()->set( 'aimeos/locale/currencyid', $currencyId );
73
		}
74
	}
75
}
76