1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-02 12:21:06 +02:00

DibiFluent::__class() small refactoring

This commit is contained in:
David Grudl
2010-08-03 08:08:05 +02:00
parent 8c5dc153f2
commit bcee7bba91

View File

@@ -132,29 +132,6 @@ class DibiFluent extends DibiObject implements IDataSource
$this->cursor = & $this->clauses[self::$clauseSwitches[$clause]];
}
// special types or argument
if (count($args) === 1) {
$arg = $args[0];
// TODO: really ignore TRUE?
if ($arg === TRUE) { // flag
$args = array();
} elseif (is_string($arg) && preg_match('#^[a-z:_][a-z0-9_.:]*$#i', $arg)) { // identifier
$args = array('%n', $arg);
} elseif ($arg instanceof self) {
$args = array_merge(array('('), $arg->_export(), array(')'));
} elseif (is_array($arg) || $arg instanceof Traversable) { // any array
if (isset(self::$modifiers[$clause])) {
$args = array(self::$modifiers[$clause], $arg);
} elseif (is_string(key($arg))) { // associative array
$args = array('%a', $arg);
}
} // case $arg === FALSE is handled below
}
if (array_key_exists($clause, $this->clauses)) {
// append to clause
$this->cursor = & $this->clauses[$clause];
@@ -188,6 +165,29 @@ class DibiFluent extends DibiObject implements IDataSource
$this->cursor = array();
}
// special types or argument
if (count($args) === 1) {
$arg = $args[0];
// TODO: really ignore TRUE?
if ($arg === TRUE) { // flag
return $this;
} elseif (is_string($arg) && preg_match('#^[a-z:_][a-z0-9_.:]*$#i', $arg)) { // identifier
$args = array('%n', $arg);
} elseif ($arg instanceof self) {
$args = array_merge(array('('), $arg->_export(), array(')'));
} elseif (is_array($arg) || $arg instanceof Traversable) { // any array
if (isset(self::$modifiers[$clause])) {
$args = array(self::$modifiers[$clause], $arg);
} elseif (is_string(key($arg))) { // associative array
$args = array('%a', $arg);
}
} // case $arg === FALSE is handled above
}
array_splice($this->cursor, count($this->cursor), 0, $args);
return $this;
}