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> | |
11 | * @package WoltLabSuite\Core\System\Database\Table\Column | |
12 | * @since 5.2 | |
f6e43f2f | 13 | */ |
a9229942 TD |
14 | interface IDatabaseTableColumn |
15 | { | |
a9229942 TD |
16 | /** |
17 | * Marks the column to be dropped and returns the column. | |
18 | * | |
19 | * @return $this | |
20 | */ | |
a8c47fb1 | 21 | public function drop(): static; |
a9229942 TD |
22 | |
23 | /** | |
24 | * Returns the data used by `DatabaseEditor` to add the column to a table. | |
a9229942 | 25 | */ |
3f13d793 | 26 | public function getData(): array; |
a9229942 | 27 | |
a9229942 TD |
28 | /** |
29 | * Returns the name of the column. | |
a9229942 | 30 | */ |
3f13d793 | 31 | public function getName(): string; |
a9229942 TD |
32 | |
33 | /** | |
34 | * Returns the new name of the column or `null` if the column's name is unchanged. | |
35 | * | |
36 | * @since 5.4 | |
37 | */ | |
38 | public function getNewName(): ?string; | |
39 | ||
40 | /** | |
41 | * Returns the type of the column. | |
a9229942 | 42 | */ |
3f13d793 | 43 | public function getType(): string; |
a9229942 TD |
44 | |
45 | /** | |
46 | * Returns `true` if the values of the column cannot be `null`. | |
a9229942 | 47 | */ |
3f13d793 | 48 | public function isNotNull(): bool; |
a9229942 TD |
49 | |
50 | /** | |
51 | * Sets the name of the column and returns the column. | |
52 | * | |
a9229942 TD |
53 | * @return $this |
54 | */ | |
a8c47fb1 | 55 | public function name(string $name): static; |
a9229942 TD |
56 | |
57 | /** | |
58 | * Sets if the values of the column cannot be `null`. | |
59 | * | |
a9229942 TD |
60 | * @return $this |
61 | */ | |
a8c47fb1 | 62 | public function notNull(bool $notNull = true): static; |
a9229942 TD |
63 | |
64 | /** | |
65 | * Sets the new name of the column and returns the column. | |
66 | * | |
67 | * @since 5.4 | |
9e8ff1e8 | 68 | * @return $this |
a9229942 | 69 | */ |
a8c47fb1 | 70 | public function renameTo(string $newName): static; |
a9229942 TD |
71 | |
72 | /** | |
73 | * Returns `true` if the column will be dropped. | |
a9229942 | 74 | */ |
3f13d793 | 75 | public function willBeDropped(): bool; |
f6e43f2f | 76 | |
a9229942 TD |
77 | /** |
78 | * Returns a `DatabaseTableColumn` object with the given name. | |
79 | * | |
a9229942 TD |
80 | * @return $this |
81 | */ | |
a8c47fb1 | 82 | public static function create(string $name): static; |
f6e43f2f | 83 | |
a9229942 TD |
84 | /** |
85 | * Returns a `DatabaseTableColumn` object with the given name and data. | |
86 | * | |
a9229942 TD |
87 | * @param array $data data returned by `DatabaseEditor::getColumns()` |
88 | * @return $this | |
89 | */ | |
a8c47fb1 | 90 | public static function createFromData(string $name, array $data): static; |
f6e43f2f | 91 | } |