Completed
Push — master ( 511775...f26102 )
by Peter
22:17
created

SearchCriteria::getDecoratorType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This software package is licensed under `AGPL, Commercial` license[s].
5
 *
6
 * @package maslosoft/manganel
7
 * @license AGPL, Commercial
8
 *
9
 * @copyright Copyright (c) Peter Maselkowski <[email protected]>
10
 * @link https://maslosoft.com/manganel/
11
 */
12
13
namespace Maslosoft\Manganel;
14
15
use Maslosoft\Addendum\Interfaces\AnnotatedInterface;
16
use Maslosoft\Mangan\Criteria;
17
use Maslosoft\Mangan\Interfaces\Decorators\ConditionDecoratorTypeAwareInterface;
18
use Maslosoft\Mangan\Interfaces\Decorators\ConditionDecoratorTypeInterface;
19
use Maslosoft\Mangan\Transformers\CriteriaArray;
20
use Maslosoft\Manganel\Traits\UniqueModelsAwareTrait;
21
22
/**
23
 * SearchCriteria
24
 *
25
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
26
 */
27
class SearchCriteria extends Criteria implements ConditionDecoratorTypeAwareInterface
28
{
29
30
	use UniqueModelsAwareTrait;
31 63
32
	private $query = '';
33 63
34 63
	public function __construct($criteria = null, AnnotatedInterface $model = null)
35
	{
36 36
		parent::__construct($criteria, $model);
37
		if (!empty($model))
38 63
		{
39
			$this->add($model);
40 36
		}
41
	}
42 36
43 36
	public function getDecoratorType()
44
	{
45
		return SearchCriteriaArray::class;
46 38
	}
47
48 38
49 38
	public function add($model)
50
	{
51 63
		$this->addModel($model);
52
		return $this;
53 63
	}
54
55
	public function search($query)
56
	{
57
		$this->query = $query;
58
	}
59
60
	public function getSearch()
61
	{
62
		return $this->query;
63
	}
64
65
}
66