/** * Get type param * @param string $key * @return IParam * */ private function getType($key) { while (in_array(substr($key, 0, 1), $this->getSpecialCharsArray())) { $key = substr($key, 1); } if (array_key_exists($key, $this->filter_rule)) { $type = $this->filter_rule[$key]; switch ($type) { case 'string': return new String($this->sql_builder); case 'number': return new Number($this->sql_builder); case 'date': return DateTime::short($this->sql_builder); case 'datetime': return DateTime::full($this->sql_builder); case 'boolean': return new Boolean($this->sql_builder); default: if ($this->config()->exists('filter_rule', $type)) { $class = $this->config()->get('filter_rule', $type); if (class_exists($class)) { return new $class($this->sql_builder); } else { throw new \InvalidArgumentException("Filter rule class `{$class}` is not exists"); } } else { throw new \InvalidArgumentException("Filter rule `{$type}` is not exists"); } } } else { throw new \InvalidArgumentException("Unknow field `{$key}`"); } }