-
Notifications
You must be signed in to change notification settings - Fork 1
/
Text.php
67 lines (59 loc) · 1.5 KB
/
Text.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
namespace ICanBoogie\ActiveRecord\Schema;
use Attribute;
#[Attribute(Attribute::TARGET_PROPERTY)]
final readonly class Text extends Column
{
/**
* A `TEXT`` with a maximum length of 255 characters.
*/
public const SIZE_TINY = 'TINY';
/**
* A `TEXT`` with a maximum length of 65535 characters.
*/
public const SIZE_REGULAR = 'REGULAR';
/**
* A `TEXT`` with a maximum length of 16777215 characters.
*/
public const SIZE_MEDIUM = 'MEDIUM';
/**
* A `TEXT`` with a maximum length of 4294967295 characters.
*/
public const SIZE_LONG = 'LONG';
/**
* @param array{
* size: self::SIZE_*,
* null: bool,
* default: ?string,
* unique: bool,
* collate: non-empty-string|null,
* } $an_array
*/
public static function __set_state(array $an_array): self
{
return new self(
$an_array['size'],
$an_array['null'],
$an_array['default'],
$an_array['unique'],
$an_array['collate'],
);
}
/**
* @param self::SIZE_* $size
*/
public function __construct(
public readonly string $size = self::SIZE_REGULAR,
bool $null = false,
?string $default = null,
bool $unique = false,
?string $collate = null,
) {
parent::__construct(
null: $null,
default: $default,
unique: $unique,
collate: $collate,
);
}
}