database = $database; $this->tables = $tables; } protected function parse_limit(?int $limit) : string { if ($limit === null) { return ''; } return 'limit '.strval($limit).' '; } protected function parse_filters( array $filters, filter_type $type = filter_type::equal, filter_glue $glue = filter_glue::all ) : string { if (empty($filters)) { return ''; } $result = new \cx_appengine\string_builder('where '); foreach ($filters as $name => $content) { $result->push($name); if ($content === null) { $result->push(' is null'); } elseif (is_numeric($content)) { $result->push($type->value.strval($content)); } elseif (is_string($content)) { $result->push($type->value.'"'.$content.'"'); } else { throw $this->get_exception('parse_filters'); } $result->push($glue->value); } return $result->cut(strlen($glue->value))->push(' ')->get(); } protected function get_exception(string $operation) : \exception { $exception = "\n\n"; $exception .= 'Can not make operation on database in class: '; $exception .= get_class($this).'. Trying to make: '.$operation.'.'; $exception .= "\n\n"; return new \exception($exception); } protected function get_has_id_exception() : \exception { $exception = "\n\n"; $exception .= 'Can not make operation on database in class: '; $exception .= get_class($this).'. Trying to insert item with ID.'; $exception .= "\n\n"; return new \exception($exception); } protected function get_blank_id_exception() : \exception { $exception = "\n\n"; $exception .= 'Can not make operation on database in class: '; $exception .= get_class($this).'. Trying to load target without ID.'; $exception .= "\n\n"; return new \exception($exception); } protected function get_tables() : table_names { return $this->tables; } protected function get_database() : wpdb { return $this->database; } private table_names $tables; private wpdb $database; }