forked from doctrine/dbal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableEditor.php
More file actions
106 lines (79 loc) · 2.46 KB
/
TableEditor.php
File metadata and controls
106 lines (79 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Exception\InvalidTableDefinition;
use Doctrine\DBAL\Schema\Name\OptionallyQualifiedName;
final class TableEditor
{
private ?OptionallyQualifiedName $name = null;
/** @var array<Column> */
private array $columns = [];
/** @var array<Index> */
private array $indexes = [];
/** @var array<UniqueConstraint> */
private array $uniqueConstraints = [];
/** @var array<ForeignKeyConstraint> */
private array $foreignKeyConstraints = [];
/** @var array<string, mixed> */
private array $options = [];
private ?TableConfiguration $configuration = null;
/** @internal Use {@link Table::editor()} or {@link Table::edit()} to create an instance */
public function __construct()
{
}
public function setName(OptionallyQualifiedName $name): self
{
$this->name = $name;
return $this;
}
/** @param array<Column> $columns */
public function setColumns(array $columns): self
{
$this->columns = $columns;
return $this;
}
/** @param array<Index> $indexes */
public function setIndexes(array $indexes): self
{
$this->indexes = $indexes;
return $this;
}
/** @param array<UniqueConstraint> $uniqueConstraints */
public function setUniqueConstraints(array $uniqueConstraints): self
{
$this->uniqueConstraints = $uniqueConstraints;
return $this;
}
/** @param array<ForeignKeyConstraint> $foreignKeyConstraints */
public function setForeignKeyConstraints(array $foreignKeyConstraints): self
{
$this->foreignKeyConstraints = $foreignKeyConstraints;
return $this;
}
/** @param array<string, mixed> $options */
public function setOptions(array $options): self
{
$this->options = $options;
return $this;
}
public function setConfiguration(TableConfiguration $configuration): self
{
$this->configuration = $configuration;
return $this;
}
public function create(): Table
{
if ($this->name === null) {
throw InvalidTableDefinition::nameNotSet();
}
return new Table(
$this->name->toString(),
$this->columns,
$this->indexes,
$this->uniqueConstraints,
$this->foreignKeyConstraints,
$this->options,
$this->configuration,
);
}
}