Flow   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getObject() 0 10 2
A __construct() 0 4 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://www.gnu.org/copyleft/lgpl.html
5
 * @copyright Aimeos (aimeos.org), 2015-2018
6
 * @package MAdmin
7
 * @subpackage Cache
8
 */
9
10
11
namespace Aimeos\MAdmin\Cache\Proxy;
12
13
14
/**
15
 * Cache proxy for creating the Flow cache object on demand.
16
 *
17
 * @package MAdmin
18
 * @subpackage Cache
19
 */
20
class Flow
21
	extends \Aimeos\MAdmin\Cache\Proxy\Standard
22
	implements \Aimeos\MW\Cache\Iface
23
{
24
	private $object;
25
	private $context;
26
	private $cache;
27
28
29
	/**
30
	 * Initializes the cache controller.
31
	 *
32
	 * @param \Aimeos\MShop\Context\Item\Iface $context MShop context object
33
	 * @param \Neos\Cache\Frontend\StringFrontend $cache Flow cache object
34
	 */
35
	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, \Neos\Cache\Frontend\StringFrontend $cache )
36
	{
37
		$this->context = $context;
38
		$this->cache = $cache;
39
	}
40
41
42
	/**
43
	 * Returns the cache object or creates a new one if it doesn't exist yet.
44
	 *
45
	 * @return \Aimeos\MW\Cache\Iface Cache object
46
	 */
47
	protected function getObject()
48
	{
49
		if( !isset( $this->object ) )
50
		{
51
			$siteid = $this->context->getLocale()->getSiteId();
52
			$conf = array( 'siteid' => $this->context->getConfig()->get( 'madmin/cache/prefix' ) . $siteid );
53
			$this->object = \Aimeos\MW\Cache\Factory::create( 'Flow', $conf, $this->cache );
54
		}
55
56
		return $this->object;
57
	}
58
}
59