| 1 | <?php |
| 2 | |
| 3 | namespace wcf\system\database\table\column; |
| 4 | |
| 5 | /** |
| 6 | * Represents a column of a database table. |
| 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 |
| 13 | */ |
| 14 | interface IDatabaseTableColumn |
| 15 | { |
| 16 | /** |
| 17 | * Marks the column to be dropped and returns the column. |
| 18 | * |
| 19 | * @return $this |
| 20 | */ |
| 21 | public function drop(): static; |
| 22 | |
| 23 | /** |
| 24 | * Returns the data used by `DatabaseEditor` to add the column to a table. |
| 25 | */ |
| 26 | public function getData(): array; |
| 27 | |
| 28 | /** |
| 29 | * Returns the name of the column. |
| 30 | */ |
| 31 | public function getName(): string; |
| 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. |
| 42 | */ |
| 43 | public function getType(): string; |
| 44 | |
| 45 | /** |
| 46 | * Returns `true` if the values of the column cannot be `null`. |
| 47 | */ |
| 48 | public function isNotNull(): bool; |
| 49 | |
| 50 | /** |
| 51 | * Sets the name of the column and returns the column. |
| 52 | * |
| 53 | * @return $this |
| 54 | */ |
| 55 | public function name(string $name): static; |
| 56 | |
| 57 | /** |
| 58 | * Sets if the values of the column cannot be `null`. |
| 59 | * |
| 60 | * @return $this |
| 61 | */ |
| 62 | public function notNull(bool $notNull = true): static; |
| 63 | |
| 64 | /** |
| 65 | * Sets the new name of the column and returns the column. |
| 66 | * |
| 67 | * @since 5.4 |
| 68 | * @return $this |
| 69 | */ |
| 70 | public function renameTo(string $newName): static; |
| 71 | |
| 72 | /** |
| 73 | * Returns `true` if the column will be dropped. |
| 74 | */ |
| 75 | public function willBeDropped(): bool; |
| 76 | |
| 77 | /** |
| 78 | * Returns a `DatabaseTableColumn` object with the given name. |
| 79 | * |
| 80 | * @return $this |
| 81 | */ |
| 82 | public static function create(string $name): static; |
| 83 | |
| 84 | /** |
| 85 | * Returns a `DatabaseTableColumn` object with the given name and data. |
| 86 | * |
| 87 | * @param array $data data returned by `DatabaseEditor::getColumns()` |
| 88 | * @return $this |
| 89 | */ |
| 90 | public static function createFromData(string $name, array $data): static; |
| 91 | } |