Completed
Push — master ( 321c29...f7acb7 )
by Peter
05:07
created

SearchCriteria   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 33
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A add() 0 5 1
A search() 0 4 1
A getSearch() 0 4 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 http://maslosoft.com/manganel/
11
 */
12
13
namespace Maslosoft\Manganel;
14
15
use Maslosoft\Addendum\Interfaces\AnnotatedInterface;
16
use Maslosoft\Mangan\Criteria;
17
use Maslosoft\Manganel\Traits\UniqueModelsAwareTrait;
18
19
/**
20
 * SearchCriteria
21
 *
22
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
23
 */
24
class SearchCriteria extends Criteria
25
{
26
27
	use UniqueModelsAwareTrait;
28
29
	private $query = '';
30
31 38
	public function __construct($criteria = null, AnnotatedInterface $model = null)
32
	{
33 38
		parent::__construct($criteria, $model);
34 38
		if (!empty($model))
35
		{
36 2
			$this->add($model);
37
		}
38 38
	}
39
40 2
	public function add($model)
41
	{
42 2
		$this->addModel($model);
43 2
		return $this;
44
	}
45
46 15
	public function search($query)
47
	{
48 15
		$this->query = $query;
49 15
	}
50
51 38
	public function getSearch()
52
	{
53 38
		return $this->query;
54
	}
55
56
}
57