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 | * @param array $container |
||
40 | */ |
||
41 | public function __construct(array $container = []) |
||
51 | |||
52 | /** |
||
53 | * Returns the query instances (by bool type). |
||
54 | * |
||
55 | * @param string|null $boolType |
||
56 | * |
||
57 | * @return array |
||
58 | */ |
||
59 | public function getQueries($boolType = null) |
||
77 | |||
78 | /** |
||
79 | * Add BuilderInterface object to bool operator. |
||
80 | * |
||
81 | * @param BuilderInterface $query Query add to the bool. |
||
82 | * @param string $type Bool type. Example: must, must_not, should. |
||
83 | * @param string $key Key that indicates a builder id. |
||
84 | * |
||
85 | * @return string Key of added builder. |
||
86 | * |
||
87 | * @throws \UnexpectedValueException |
||
88 | */ |
||
89 | public function add(BuilderInterface $query, $type = self::MUST, $key = null) |
||
103 | |||
104 | /** |
||
105 | * {@inheritdoc} |
||
106 | */ |
||
107 | public function toArray() |
||
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | public function getType() |
||
141 | } |
||
142 |
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: