3
namespace Upside\Db\Schema;
7
protected string $name;
8
protected ?string $type;
9
protected array $properties = [];
11
public function __construct(string $name, ?string $type = null)
17
public function get_name(): string
22
public function get_type(): string
27
public function get_properties(): array
29
return $this->properties;
32
public function set_type(string $type): static
39
public function set(string $name, $value): static
41
$this->properties[$name] = $value;
46
public function has(string $name): bool
48
return isset($this->properties[$name]);
51
public function get(string $name, mixed $default = null): mixed
53
return $this->properties[$name] ?? $default;
56
public function size(string $value): static
58
$value = \strtolower($value);
60
if (!\in_array($value, ['tiny', 'small', 'normal', 'medium', 'big'])) {
64
return $this->set('size', $value);
67
public function not_null(): static
69
return $this->set('nullable', false);
72
public function description(string $comment): static
74
return $this->set('description', $comment);
77
public function default_value($value): static
79
return $this->set('default', $value);
82
public function unsigned(bool $value = true): static
84
return $this->set('unsigned', $value);
87
public function length($value): static
89
return $this->set('length', $value);