public function __call($name, array $arguments) { if (preg_match('#^(' . implode('|', static::$magicMethodsPrefixes) . ')(.+)$#', $name, $matches)) { if (count($arguments) !== 1) { throw new InvalidMethodCallException(get_called_class() . "::{$name} expects exactly 1 argument. " . count($arguments) . ' given.'); } list($query) = $arguments; if (!$query instanceof IQuery) { throw new InvalidArgumentException('Argument 1 passed to ' . get_called_class() . "::{$name} must implement interface Inlm\\QueryObject\\IQuery. " . gettype($query) . ' given.'); } list(, $method, $field) = $matches; $field = lcfirst($field); return $this->{$method}($field, $query); } else { return parent::__call($name, $arguments); } }