Commit | Line | Data |
---|---|---|
f6e43f2f | 1 | <?php |
a9229942 | 2 | |
f6e43f2f MS |
3 | namespace wcf\system\database\table\column; |
4 | ||
5 | /** | |
6 | * Represents a column of a database table. | |
a9229942 TD |
7 | * |
8 | * @author Matthias Schmidt | |
9 | * @copyright 2001-2019 WoltLab GmbH | |
10 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
a9229942 | 11 | * @since 5.2 |
f6e43f2f | 12 | */ |
a9229942 TD |
13 | interface IDatabaseTableColumn |
14 | { | |
a9229942 TD |
15 | /** |
16 | * Marks the column to be dropped and returns the column. | |
17 | * | |
18 | * @return $this | |
19 | */ | |
a8c47fb1 | 20 | public function drop(): static; |
a9229942 TD |
21 | |
22 | /** | |
23 | * Returns the data used by `DatabaseEditor` to add the column to a table. | |
a9229942 | 24 | */ |
3f13d793 | 25 | public function getData(): array; |
a9229942 | 26 | |
a9229942 TD |
27 | /** |
28 | * Returns the name of the column. | |
a9229942 | 29 | */ |
3f13d793 | 30 | public function getName(): string; |
a9229942 TD |
31 | |
32 | /** | |
33 | * Returns the new name of the column or `null` if the column's name is unchanged. | |
34 | * | |
35 | * @since 5.4 | |
36 | */ | |
37 | public function getNewName(): ?string; | |
38 | ||
39 | /** | |
40 | * Returns the type of the column. | |
a9229942 | 41 | */ |
3f13d793 | 42 | public function getType(): string; |
a9229942 TD |
43 | |
44 | /** | |
45 | * Returns `true` if the values of the column cannot be `null`. | |
a9229942 | 46 | */ |
3f13d793 | 47 | public function isNotNull(): bool; |
a9229942 TD |
48 | |
49 | /** | |
50 | * Sets the name of the column and returns the column. | |
51 | * | |
a9229942 TD |
52 | * @return $this |
53 | */ | |
a8c47fb1 | 54 | public function name(string $name): static; |
a9229942 TD |
55 | |
56 | /** | |
57 | * Sets if the values of the column cannot be `null`. | |
58 | * | |
a9229942 TD |
59 | * @return $this |
60 | */ | |
a8c47fb1 | 61 | public function notNull(bool $notNull = true): static; |
a9229942 TD |
62 | |
63 | /** | |
64 | * Sets the new name of the column and returns the column. | |
65 | * | |
66 | * @since 5.4 | |
9e8ff1e8 | 67 | * @return $this |
a9229942 | 68 | */ |
a8c47fb1 | 69 | public function renameTo(string $newName): static; |
a9229942 TD |
70 | |
71 | /** | |
72 | * Returns `true` if the column will be dropped. | |
a9229942 | 73 | */ |
3f13d793 | 74 | public function willBeDropped(): bool; |
f6e43f2f | 75 | |
a9229942 TD |
76 | /** |
77 | * Returns a `DatabaseTableColumn` object with the given name. | |
78 | * | |
a9229942 TD |
79 | * @return $this |
80 | */ | |
a8c47fb1 | 81 | public static function create(string $name): static; |
f6e43f2f | 82 | |
a9229942 TD |
83 | /** |
84 | * Returns a `DatabaseTableColumn` object with the given name and data. | |
85 | * | |
a9229942 TD |
86 | * @param array $data data returned by `DatabaseEditor::getColumns()` |
87 | * @return $this | |
88 | */ | |
a8c47fb1 | 89 | public static function createFromData(string $name, array $data): static; |
f6e43f2f | 90 | } |