loadedFromAdapter]; return Ulmus::repository(static::class, $alias, $adapter); }*/ # TODO ! Handle FUNCTIONAL default value protected function canHaveDefaultValue(): bool { return ! in_array(strtoupper($this->dataType), [ # 'BLOB', 'TINYBLOB', 'MEDIUMBLOB', 'LONGBLOB', 'JSON', 'TEXT', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'GEOMETRY' ]); } protected function defaultValue() : mixed { if ($this->default === null) { return null; } # Removing first pairs of brackets $default = $this->isBetween($this->default, '(', ')') ? substr($this->default, 1, -1) : $this->default; if ($default === "NULL") { return null; } # Checking if another pairs of brackets surrounds the value if ($this->isBetween($default, '(', ')')) { $default = substr($default, 1, -1); if (is_numeric($default)) { return (int) $default; } } elseif ($this->isBetween($default, "'", "'")) { $default = new class($default) implements \Stringable { public function __construct( private readonly string $default ) {} public function __toString(): string { return substr($this->default, 1, -1);; } }; } else { $default = new class($default) implements \Stringable { public function __construct( private readonly string $default ) {} public function __toString(): string { return $this->default; } }; } return (string) $default; } private function isBetween(string $str, string $first, string $last) : bool { return str_starts_with($str, $first) && str_ends_with($str, $last); } }