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