1 | <?php |
||
22 | class BoolQuery implements BuilderInterface |
||
23 | { |
||
24 | use ParametersTrait; |
||
25 | |||
26 | const MUST = 'must'; |
||
27 | const MUST_NOT = 'must_not'; |
||
28 | const SHOULD = 'should'; |
||
29 | const FILTER = 'filter'; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | private $container = []; |
||
35 | |||
36 | /** |
||
37 | * Constructor to prepare container. |
||
38 | */ |
||
39 | public function __construct() |
||
43 | |||
44 | /** |
||
45 | * Returns the query instances (by bool type). |
||
46 | * |
||
47 | * @param string|null $boolType |
||
48 | * |
||
49 | * @return array |
||
50 | */ |
||
51 | public function getQueries($boolType = null) |
||
69 | |||
70 | /** |
||
71 | * Add BuilderInterface object to bool operator. |
||
72 | * |
||
73 | * @param BuilderInterface $query Query add to the bool. |
||
74 | * @param string $type Bool type. Example: must, must_not, should. |
||
75 | * @param string $key Key that indicates a builder id. |
||
76 | * |
||
77 | * @return string Key of added builder. |
||
78 | * |
||
79 | * @throws \UnexpectedValueException |
||
80 | */ |
||
81 | public function add(BuilderInterface $query, $type = self::MUST, $key = null) |
||
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | public function toArray() |
||
121 | |||
122 | /** |
||
123 | * {@inheritdoc} |
||
124 | */ |
||
125 | public function getType() |
||
129 | } |
||
130 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: