add($part); } return $this; } /** * Adds an expression to composite expression. * * @param mixed $part * * @return \OCP\DB\QueryBuilder\ICompositeExpression */ public function add($part): ICompositeExpression { if ($part === null) { return $this; } if ($part instanceof self && count($part) === 0) { return $this; } $this->parts[] = $part; return $this; } /** * Retrieves the amount of expressions on composite expression. * * @return integer */ public function count(): int { return count($this->parts); } /** * Returns the type of this composite expression (AND/OR). * * @return string */ public function getType(): string { return $this->type; } /** * Retrieves the string representation of this composite expression. * * @return string */ public function __toString(): string { if ($this->count() === 1) { return (string)$this->parts[0]; } return '(' . implode(') ' . $this->type . ' (', $this->parts) . ')'; } public function getParts(): array { return $this->parts; } }