Exception
2 years ago
Visitor
9 months ago
AbstractAsset.php
2 years ago
AbstractSchemaManager.php
9 months ago
Column.php
2 years ago
ColumnDiff.php
2 years ago
Comparator.php
2 years ago
Constraint.php
2 years ago
DB2SchemaManager.php
2 years ago
DefaultSchemaManagerFactory.php
2 years ago
ForeignKeyConstraint.php
9 months ago
Identifier.php
2 years ago
Index.php
2 years ago
LegacySchemaManagerFactory.php
2 years ago
MySQLSchemaManager.php
9 months ago
OracleSchemaManager.php
2 years ago
PostgreSQLSchemaManager.php
9 months ago
SQLServerSchemaManager.php
9 months ago
Schema.php
2 years ago
SchemaConfig.php
2 years ago
SchemaDiff.php
2 years ago
SchemaException.php
2 years ago
SchemaManagerFactory.php
2 years ago
Sequence.php
2 years ago
SqliteSchemaManager.php
8 months ago
Table.php
2 years ago
TableDiff.php
2 years ago
UniqueConstraint.php
2 years ago
View.php
2 years ago
UniqueConstraint.php
74 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Doctrine\DBAL\Schema; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform; |
| 5 | use function array_keys; |
| 6 | use function array_map; |
| 7 | use function strtolower; |
| 8 | class UniqueConstraint extends AbstractAsset implements Constraint |
| 9 | { |
| 10 | protected $columns = []; |
| 11 | protected $flags = []; |
| 12 | private array $options; |
| 13 | public function __construct(string $name, array $columns, array $flags = [], array $options = []) |
| 14 | { |
| 15 | $this->_setName($name); |
| 16 | $this->options = $options; |
| 17 | foreach ($columns as $column) { |
| 18 | $this->addColumn($column); |
| 19 | } |
| 20 | foreach ($flags as $flag) { |
| 21 | $this->addFlag($flag); |
| 22 | } |
| 23 | } |
| 24 | public function getColumns() |
| 25 | { |
| 26 | return array_keys($this->columns); |
| 27 | } |
| 28 | public function getQuotedColumns(AbstractPlatform $platform) |
| 29 | { |
| 30 | $columns = []; |
| 31 | foreach ($this->columns as $column) { |
| 32 | $columns[] = $column->getQuotedName($platform); |
| 33 | } |
| 34 | return $columns; |
| 35 | } |
| 36 | public function getUnquotedColumns() : array |
| 37 | { |
| 38 | return array_map([$this, 'trimQuotes'], $this->getColumns()); |
| 39 | } |
| 40 | public function getFlags() : array |
| 41 | { |
| 42 | return array_keys($this->flags); |
| 43 | } |
| 44 | public function addFlag(string $flag) : UniqueConstraint |
| 45 | { |
| 46 | $this->flags[strtolower($flag)] = \true; |
| 47 | return $this; |
| 48 | } |
| 49 | public function hasFlag(string $flag) : bool |
| 50 | { |
| 51 | return isset($this->flags[strtolower($flag)]); |
| 52 | } |
| 53 | public function removeFlag(string $flag) : void |
| 54 | { |
| 55 | unset($this->flags[strtolower($flag)]); |
| 56 | } |
| 57 | public function hasOption(string $name) : bool |
| 58 | { |
| 59 | return isset($this->options[strtolower($name)]); |
| 60 | } |
| 61 | public function getOption(string $name) |
| 62 | { |
| 63 | return $this->options[strtolower($name)]; |
| 64 | } |
| 65 | public function getOptions() : array |
| 66 | { |
| 67 | return $this->options; |
| 68 | } |
| 69 | protected function addColumn(string $column) : void |
| 70 | { |
| 71 | $this->columns[$column] = new Identifier($column); |
| 72 | } |
| 73 | } |
| 74 |