protected function _operator($key, $value, array $schema = array(), array $options = array())
{
$defaults = array('boolean' => 'AND');
$options += $defaults;
list($op, $value) = each($value);
$op = strtoupper($op);
$config = $this->_operators[$op];
$key = $this->name($key);
$values = array();
if (!is_object($value)) {
if ($value === null) {
$value = array(null);
}
foreach ((array) $value as $val) {
$values[] = $this->value($val, $schema);
}
} elseif (isset($value->scalar)) {
return "{$key} {$op} {$value->scalar}";
}
switch (true) {
case isset($config['format']):
return $key . ' ' . String::insert($config['format'], $values);
case is_object($value) && isset($config['multiple']):
$op = $config['multiple'];
$value = trim(rtrim($this->renderCommand($value), ';'));
return "{$key} {$op} ({$value})";
case count($values) > 1 && isset($config['multiple']):
$op = $config['multiple'];
$values = join(', ', $values);
return "{$key} {$op} ({$values})";
case count($values) > 1:
return join(" {$options['boolean']} ", array_map(function ($v) use($key, $op) {
return "{$key} {$op} {$v}";
}, $values));
}
return "{$key} {$op} {$values[0]}";
}