5use InvalidArgumentException;
28 $this->children[] = $expression;
31 abstract protected function getType(): string;
42 throw new InvalidArgumentException(
"The array of conditions can't be empty." );
45 foreach ( $conds as $field => $cond ) {
46 if ( is_numeric( $field ) ) {
48 throw new InvalidArgumentException(
49 __METHOD__ .
": Only IExpression are allowed with numeric key." );
54 throw new InvalidArgumentException( __METHOD__ .
": unexpected key $field for IExpression value" );
56 $exprs[] =
new Expression( $field,
'=', $cond );
60 return new static( ...$exprs );
69 if ( !$this->children ) {
70 throw new InvalidArgumentException(
"The array of values can't be empty." );
72 $sqls = array_map(
static fn ( $value ) => $value->toSql( $dbQuoter ), $this->children );
73 return '(' . implode(
' ' . $this->
getType() .
' ', $sqls ) .
')';
77 if ( !$this->children ) {
78 throw new InvalidArgumentException(
"The array of values can't be empty." );
80 $sqls = array_map(
static fn ( $value ) => $value->toGeneralizedSql(), $this->children );
81 return '(' . implode(
' ' . $this->getType() .
' ', $sqls ) .
')';
if(!defined('MW_SETUP_CALLBACK'))