| 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 = [], $type = 'AND') |
|
| 42 | |||
| 43 | /** |
||
| 44 | * Adds an expression to composite expression. |
||
| 45 | * |
||
| 46 | * @param mixed $parts |
||
| 47 | * |
||
| 48 | * @return CompositeBuilder |
||
| 49 | */ |
||
| 50 | 3 | public function add($parts) |
|
| 60 | |||
| 61 | /** |
||
| 62 | * Return type of this composite |
||
| 63 | * |
||
| 64 | * @return string |
||
| 65 | */ |
||
| 66 | 3 | public function getType() |
|
| 70 | |||
| 71 | /** |
||
| 72 | * Retrieves the amount of expressions on composite expression. |
||
| 73 | * |
||
| 74 | * @return integer |
||
| 75 | */ |
||
| 76 | public function count() |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Retrieve the string representation of this composite expression. |
||
| 83 | * |
||
| 84 | * @return string |
||
| 85 | */ |
||
| 86 | 3 | public function __toString() |
|
| 93 | } |
||
| 94 |