SingleModelDecorator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 23
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A decorate() 0 16 3
1
<?php
2
3
/**
4
 * This software package is licensed under `AGPL-3.0-only, proprietary` license[s].
5
 *
6
 * @package maslosoft/manganel
7
 * @license AGPL-3.0-only, proprietary
8
 *
9
 * @copyright Copyright (c) Peter Maselkowski <[email protected]>
10
 * @link https://maslosoft.com/manganel/
11
 */
12
13
namespace Maslosoft\Manganel\Decorators\QueryBuilder;
14
15
use Maslosoft\Gazebo\PluginFactory;
16
use Maslosoft\Mangan\Interfaces\ModelAwareInterface;
17
use Maslosoft\Mangan\Traits\ModelAwareTrait;
18
use Maslosoft\Manganel\Interfaces\ManganelAwareInterface;
19
use Maslosoft\Manganel\Interfaces\QueryBuilder\BodyDecoratorInterface;
20
use Maslosoft\Manganel\SearchCriteria;
21
use Maslosoft\Manganel\Traits\ManganelAwareTrait;
22
23
/**
24
 * SingleModelDecorator
25
 *
26
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
27
 */
28
class SingleModelDecorator implements ManganelAwareInterface
29
{
30
31
	use ManganelAwareTrait;
32
33 32
	public function decorate(&$body, SearchCriteria $criteria)
34
	{
35 32
		$decorators = (new PluginFactory())->instance($this->getManganel()->decorators, $criteria, [
36 32
			BodyDecoratorInterface::class
37
		]);
38
39 32
		foreach ($decorators as $decorator)
40
		{
41
			/* @var $decorator BodyDecoratorInterface  */
42 32
			if ($decorator instanceof ManganelAwareInterface)
43
			{
44 32
				$decorator->setManganel($this->manganel);
45
			}
46 32
			$decorator->decorate($body, $criteria);
47
		}
48 32
	}
49
50
}
51