Decorator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A init() 0 5 1
A decorated() 0 4 1
1
<?php
2
3
/**
4
 * This software package is licensed under `AGPL, Commercial` license[s].
5
 *
6
 * @package maslosoft/zamm
7
 * @license AGPL, Commercial
8
 *
9
 * @copyright Copyright (c) Peter Maselkowski <[email protected]>
10
 * @link https://maslosoft.com/zamm/
11
 */
12
13
namespace Maslosoft\Zamm\Decorators;
14
15
use Maslosoft\Zamm\Interfaces\DecoratorInterface;
16
use Maslosoft\Zamm\Interfaces\Decorators\RendererDecoratorInterface;
17
use Maslosoft\Zamm\Interfaces\Renderers\RendererInterface;
18
use Maslosoft\Zamm\Zamm;
19
20
/**
21
 * Decorator
22
 *
23
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
24
 */
25
class Decorator extends AbstractDecorator
26
{
27
28
	/**
29
	 * Renderer instance
30
	 * @var RendererInterface
31
	 */
32
	private $renderer = null;
33
34
	/**
35
	 * Create decorator
36
	 * @param RendererInterface $renderer
37
	 */
38
	public function __construct(RendererInterface $renderer)
39
	{
40
		$zamm = new Zamm();
41
		$this->renderer = $renderer;
42
		$this->apply($zamm->decorators);
43
	}
44
45
	protected function init(DecoratorInterface $decorator)
46
	{
47
		assert($decorator instanceof RendererDecoratorInterface);
48
		$decorator->setRenderer($this->renderer);
49
	}
50
51
	protected function decorated()
52
	{
53
		return $this->renderer;
54
	}
55
56
}
57