1 | <?php |
||
18 | class CompositeBuilder implements \Countable |
||
19 | { |
||
20 | /** |
||
21 | * @var string type AND|OR |
||
22 | */ |
||
23 | private $type; |
||
24 | |||
25 | /** |
||
26 | * @var array parts of the composite expression |
||
27 | */ |
||
28 | private $parts = []; |
||
29 | |||
30 | /** |
||
31 | * Constructor |
||
32 | * |
||
33 | * @param array $parts parts of the composite expression |
||
34 | * @param string $type AND|OR |
||
35 | */ |
||
36 | 3 | public function __construct(array $parts = [], string $type = 'AND') |
|
42 | |||
43 | /** |
||
44 | * Adds a set of expressions to composite expression |
||
45 | * |
||
46 | * @param array $parts |
||
47 | * |
||
48 | * @return CompositeBuilder |
||
49 | */ |
||
50 | 3 | public function addParts($parts) : CompositeBuilder |
|
58 | |||
59 | /** |
||
60 | * Adds an expression to composite expression |
||
61 | * |
||
62 | * @param mixed $part |
||
63 | * |
||
64 | * @return CompositeBuilder |
||
65 | */ |
||
66 | 3 | public function addPart($part) : CompositeBuilder |
|
73 | |||
74 | /** |
||
75 | * Return type of this composite |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | 3 | public function getType() : string |
|
83 | |||
84 | /** |
||
85 | * Retrieves the amount of expressions on composite expression. |
||
86 | * |
||
87 | * @return integer |
||
88 | */ |
||
89 | 3 | public function count() : int |
|
93 | |||
94 | /** |
||
95 | * Retrieve the string representation of this composite expression. |
||
96 | * |
||
97 | * @return string |
||
98 | */ |
||
99 | 3 | public function __toString() |
|
106 | } |
||
107 |