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 | */ | |
21 | public function drop(); | |
22 | ||
23 | /** | |
24 | * Returns the data used by `DatabaseEditor` to add the column to a table. | |
25 | * | |
26 | * @return array | |
27 | */ | |
28 | public function getData(); | |
29 | ||
a9229942 TD |
30 | /** |
31 | * Returns the name of the column. | |
32 | * | |
33 | * @return string | |
34 | */ | |
35 | public function getName(); | |
36 | ||
37 | /** | |
38 | * Returns the new name of the column or `null` if the column's name is unchanged. | |
39 | * | |
40 | * @since 5.4 | |
41 | */ | |
42 | public function getNewName(): ?string; | |
43 | ||
44 | /** | |
45 | * Returns the type of the column. | |
46 | * | |
47 | * @return string | |
48 | */ | |
49 | public function getType(); | |
50 | ||
51 | /** | |
52 | * Returns `true` if the values of the column cannot be `null`. | |
53 | * | |
54 | * @return bool | |
55 | */ | |
56 | public function isNotNull(); | |
57 | ||
58 | /** | |
59 | * Sets the name of the column and returns the column. | |
60 | * | |
61 | * @param string $name | |
62 | * @return $this | |
63 | */ | |
64 | public function name($name); | |
65 | ||
66 | /** | |
67 | * Sets if the values of the column cannot be `null`. | |
68 | * | |
69 | * @param bool $notNull | |
70 | * @return $this | |
71 | */ | |
72 | public function notNull($notNull = true); | |
73 | ||
74 | /** | |
75 | * Sets the new name of the column and returns the column. | |
76 | * | |
77 | * @since 5.4 | |
9e8ff1e8 | 78 | * @return $this |
a9229942 | 79 | */ |
9e8ff1e8 | 80 | public function renameTo(string $newName); |
a9229942 TD |
81 | |
82 | /** | |
83 | * Returns `true` if the column will be dropped. | |
84 | * | |
85 | * @return bool | |
86 | */ | |
87 | public function willBeDropped(); | |
f6e43f2f | 88 | |
a9229942 TD |
89 | /** |
90 | * Returns a `DatabaseTableColumn` object with the given name. | |
91 | * | |
92 | * @param string $name | |
93 | * @return $this | |
94 | */ | |
95 | public static function create($name); | |
f6e43f2f | 96 | |
a9229942 TD |
97 | /** |
98 | * Returns a `DatabaseTableColumn` object with the given name and data. | |
99 | * | |
100 | * @param string $name | |
101 | * @param array $data data returned by `DatabaseEditor::getColumns()` | |
102 | * @return $this | |
103 | */ | |
104 | public static function createFromData($name, array $data); | |
f6e43f2f | 105 | } |