-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFilterable.php
More file actions
37 lines (30 loc) · 860 Bytes
/
Filterable.php
File metadata and controls
37 lines (30 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace UniMapper\Query;
use UniMapper\Entity;
use UniMapper\Exception;
use UniMapper\Entity\Reflection;
trait Filterable
{
/** @var array */
protected $filter = [];
public function setFilter(array $filter = [])
{
try {
Entity\Filter::validate($this->reflection, $filter);
} catch (Exception\FilterException $e) {
throw new Exception\QueryException($e->getMessage());
}
$this->filter = $filter;
return $this;
}
public function where(array $filter)
{
try {
Entity\Filter::validate($this->reflection, $filter);
} catch (Exception\FilterException $e) {
throw new Exception\QueryException($e->getMessage());
}
$this->filter = Entity\Filter::merge($this->filter, $filter);
return $this;
}
}