1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2018 Robin Appelman <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @license GNU AGPL version 3 or any later version |
6
|
|
|
* |
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License as |
9
|
|
|
* published by the Free Software Foundation, either version 3 of the |
10
|
|
|
* License, or (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace SearchDAV\Query; |
23
|
|
|
|
24
|
|
|
class Operator { |
25
|
|
|
const OPERATION_AND = '{DAV:}and'; |
26
|
|
|
const OPERATION_OR = '{DAV:}or'; |
27
|
|
|
const OPERATION_NOT = '{DAV:}not'; |
28
|
|
|
const OPERATION_EQUAL = '{DAV:}eq'; |
29
|
|
|
const OPERATION_LESS_THAN = '{DAV:}lt'; |
30
|
|
|
const OPERATION_LESS_OR_EQUAL_THAN = '{DAV:}lte'; |
31
|
|
|
const OPERATION_GREATER_THAN = '{DAV:}gt'; |
32
|
|
|
const OPERATION_GREATER_OR_EQUAL_THAN = '{DAV:}gte'; |
33
|
|
|
const OPERATION_IS_COLLECTION = '{DAV:}is-collection'; |
34
|
|
|
const OPERATION_IS_DEFINED = '{DAV:}is-defined'; |
35
|
|
|
const OPERATION_IS_LIKE = '{DAV:}like'; |
36
|
|
|
const OPERATION_CONTAINS = '{DAV:}contains'; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var string |
40
|
|
|
* |
41
|
|
|
* The type of operation, one of the Operator::OPERATION_* constants |
42
|
|
|
*/ |
43
|
|
|
public $type; |
44
|
|
|
/** |
45
|
|
|
* @var (Literal|SearchPropDefinition|Operation)[] |
46
|
|
|
* |
47
|
|
|
* The list of arguments for the operation |
48
|
|
|
* |
49
|
|
|
* - SearchPropDefinition: property for comparison |
50
|
|
|
* - Literal: literal value for comparison |
51
|
|
|
* - Operation: nested operation for and/or/not operations |
52
|
|
|
* |
53
|
|
|
* Which type and what number of argument an Operator takes depends on the operator type. |
54
|
|
|
*/ |
55
|
|
|
public $arguments; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Operator constructor. |
59
|
|
|
* |
60
|
|
|
* @param string $type |
61
|
|
|
* @param array $arguments |
62
|
|
|
*/ |
63
|
|
|
public function __construct($type = '', array $arguments = []) { |
64
|
|
|
$this->type = $type; |
65
|
|
|
$this->arguments = $arguments; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|