entityClass = $entityClass; $this->name = $name; $this->alias = $alias; $this->entityResolver = $resolver; } public function name($useAlias = true) : string { $name = $this->entityResolver->searchFieldAnnotation($this->name, new Field() )->name ?? $this->name; $name = $this->entityResolver->databaseAdapter()->adapter()->escapeIdentifier($name, AdapterInterface::IDENTIFIER_FIELD); return $useAlias ? "{$this->alias}.$name" : $name; } public static function isScalarType($type) : bool { switch($type) { case 'int': case 'bool': case 'string': case 'float': case 'double': return true; } return false; } public static function generateCreateColumn($field) : string { $definition = new FieldDefinition($field); # column_name data_type(length) [NOT NULL] [DEFAULT value] [AUTO_INCREMENT] column_constraint; return implode(" ", [ $definition->getSqlName(), $definition->getSqlType(), ]); } public static function isObjectType($type) : bool { # @ Should be fixed with isBuiltIn() instead, it won't be correct based only on name # return strpos($type, "\\") !== false; } public function __toString() : string { return $this->name(); } }