From bf6655a534a6775d30cafa67bd801276bda1d98d Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 13 Aug 2024 23:45:21 +0200 Subject: =?UTF-8?q?VERSION=200.2=20doctrine=20ORM=20et=20entit=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vendor/doctrine/dbal/src/Schema/Column.php | 252 +++++++++++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 vendor/doctrine/dbal/src/Schema/Column.php (limited to 'vendor/doctrine/dbal/src/Schema/Column.php') diff --git a/vendor/doctrine/dbal/src/Schema/Column.php b/vendor/doctrine/dbal/src/Schema/Column.php new file mode 100644 index 0000000..8963cd7 --- /dev/null +++ b/vendor/doctrine/dbal/src/Schema/Column.php @@ -0,0 +1,252 @@ + */ + protected array $_platformOptions = []; + + protected ?string $_columnDefinition = null; + + protected string $_comment = ''; + + /** + * Creates a new Column. + * + * @param array $options + */ + public function __construct(string $name, Type $type, array $options = []) + { + $this->_setName($name); + $this->setType($type); + $this->setOptions($options); + } + + /** @param array $options */ + public function setOptions(array $options): self + { + foreach ($options as $name => $value) { + $method = 'set' . $name; + + if (! method_exists($this, $method)) { + throw UnknownColumnOption::new($name); + } + + $this->$method($value); + } + + return $this; + } + + public function setType(Type $type): self + { + $this->_type = $type; + + return $this; + } + + public function setLength(?int $length): self + { + $this->_length = $length; + + return $this; + } + + public function setPrecision(?int $precision): self + { + $this->_precision = $precision; + + return $this; + } + + public function setScale(int $scale): self + { + $this->_scale = $scale; + + return $this; + } + + public function setUnsigned(bool $unsigned): self + { + $this->_unsigned = $unsigned; + + return $this; + } + + public function setFixed(bool $fixed): self + { + $this->_fixed = $fixed; + + return $this; + } + + public function setNotnull(bool $notnull): self + { + $this->_notnull = $notnull; + + return $this; + } + + public function setDefault(mixed $default): self + { + $this->_default = $default; + + return $this; + } + + /** @param array $platformOptions */ + public function setPlatformOptions(array $platformOptions): self + { + $this->_platformOptions = $platformOptions; + + return $this; + } + + public function setPlatformOption(string $name, mixed $value): self + { + $this->_platformOptions[$name] = $value; + + return $this; + } + + public function setColumnDefinition(?string $value): self + { + $this->_columnDefinition = $value; + + return $this; + } + + public function getType(): Type + { + return $this->_type; + } + + public function getLength(): ?int + { + return $this->_length; + } + + public function getPrecision(): ?int + { + return $this->_precision; + } + + public function getScale(): int + { + return $this->_scale; + } + + public function getUnsigned(): bool + { + return $this->_unsigned; + } + + public function getFixed(): bool + { + return $this->_fixed; + } + + public function getNotnull(): bool + { + return $this->_notnull; + } + + public function getDefault(): mixed + { + return $this->_default; + } + + /** @return array */ + public function getPlatformOptions(): array + { + return $this->_platformOptions; + } + + public function hasPlatformOption(string $name): bool + { + return isset($this->_platformOptions[$name]); + } + + public function getPlatformOption(string $name): mixed + { + return $this->_platformOptions[$name]; + } + + public function getColumnDefinition(): ?string + { + return $this->_columnDefinition; + } + + public function getAutoincrement(): bool + { + return $this->_autoincrement; + } + + public function setAutoincrement(bool $flag): self + { + $this->_autoincrement = $flag; + + return $this; + } + + public function setComment(string $comment): self + { + $this->_comment = $comment; + + return $this; + } + + public function getComment(): string + { + return $this->_comment; + } + + /** @return array */ + public function toArray(): array + { + return array_merge([ + 'name' => $this->_name, + 'type' => $this->_type, + 'default' => $this->_default, + 'notnull' => $this->_notnull, + 'length' => $this->_length, + 'precision' => $this->_precision, + 'scale' => $this->_scale, + 'fixed' => $this->_fixed, + 'unsigned' => $this->_unsigned, + 'autoincrement' => $this->_autoincrement, + 'columnDefinition' => $this->_columnDefinition, + 'comment' => $this->_comment, + ], $this->_platformOptions); + } +} -- cgit v1.2.3