Completed
Push — master ( 4a9289...6c8c8c )
by Peter
08:35
created

QueryBuilderDecorator::decorate()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 2
crap 3
1
<?php
2
3
/*
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
namespace Maslosoft\Manganel\Helpers;
10
11
use Maslosoft\Gazebo\PluginFactory;
12
use Maslosoft\Manganel\Interfaces\ManganelAwareInterface;
13
use Maslosoft\Manganel\Interfaces\QueryBuilder\BodyDecoratorInterface;
14
use Maslosoft\Manganel\Manganel;
15
use Maslosoft\Manganel\SearchCriteria;
16
17
/**
18
 * QueryBuilderDecorator
19
 *
20
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
21
 */
22
class QueryBuilderDecorator
23
{
24
25
	/**
26
	 * Manganel instance
27
	 * @var Mangangel
28
	 */
29
	private $manganel = null;
30
31 10
	public function __construct(Manganel $manganel)
32
	{
33 10
		$this->manganel = $manganel;
0 ignored issues
show
Documentation Bug introduced by
It seems like $manganel of type object<Maslosoft\Manganel\Manganel> is incompatible with the declared type object<Maslosoft\Manganel\Helpers\Mangangel> of property $manganel.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
34 10
	}
35
36 10
	public function decorate(&$body, SearchCriteria $criteria)
37
	{
38 10
		$decorators = (new PluginFactory())->instance($this->manganel->decorators, $criteria, [
39
			BodyDecoratorInterface::class
40 10
		]);
41
42 10
		foreach ($decorators as $decorator)
43
		{
44
			/* @var $decorator BodyDecoratorInterface  */
45 10
			if ($decorator instanceof ManganelAwareInterface)
46 10
			{
47 10
				$decorator->setManganel($this->manganel);
48 10
			}
49 10
			$decorator->decorate($body, $criteria);
50 10
		}
51 10
	}
52
53
}
54