Completed
Push — master ( dc433d...4234c3 )
by Aimeos
08:12
created

Singleton::update()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 12
rs 9.4285
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017
6
 * @package MShop
7
 * @subpackage Plugin
8
 */
9
10
11
namespace Aimeos\MShop\Plugin\Provider\Decorator;
12
13
14
/**
15
 * Prevent recursive plugin calls
16
 *
17
 * @package MShop
18
 * @subpackage Plugin
19
 */
20
class Singleton
21
	extends \Aimeos\MShop\Plugin\Provider\Decorator\Base
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces between "Base" and comma; 1 found
Loading history...
22
	implements \Aimeos\MShop\Plugin\Provider\Decorator\Iface
23
{
24
	private $singleton = false;
25
26
27
	/**
28
	 * Receives a notification from a publisher object
29
	 *
30
	 * @param \Aimeos\MW\Observer\Publisher\Iface $order Shop basket instance implementing publisher interface
31
	 * @param string $action Name of the action to listen for
32
	 * @param mixed $value Object or value changed in publisher
33
	 */
34
	public function update( \Aimeos\MW\Observer\Publisher\Iface $order, $action, $value = null )
35
	{
36
		if( $this->singleton === true ) {
37
			return true;
38
		}
39
40
		$this->singleton = true;
41
		$result = $this->getProvider()->update( $order, $action, $value );
42
		$this->singleton = false;
43
44
		return $result;
45
	}
46
}
47