Namespace and ClassPath rewrites

This commit is contained in:
2022-11-18 18:06:46 +01:00
parent c277aababc
commit 951ff14c5f
217 changed files with 1017 additions and 936 deletions

View File

@@ -0,0 +1,11 @@
<?php
namespace Core\Driver\SQL\Column;
class BigIntColumn extends IntColumn {
public function __construct(string $name, bool $nullable, $defaultValue, bool $unsigned) {
parent::__construct($name, $nullable, $defaultValue, $unsigned);
$this->type = "BIGINT";
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Core\Driver\SQL\Column;
class BoolColumn extends Column {
public function __construct(string $name, bool $defaultValue = false) {
parent::__construct($name, false, $defaultValue);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Core\Driver\SQL\Column;
use Core\Driver\SQL\Expression\Expression;
class Column extends Expression {
private string $name;
private bool $nullable;
private $defaultValue;
public function __construct(string $name, bool $nullable = false, $defaultValue = NULL) {
$this->name = $name;
$this->nullable = $nullable;
$this->defaultValue = $defaultValue;
}
public function getName(): string { return $this->name; }
public function notNull(): bool { return !$this->nullable; }
public function getDefaultValue() { return $this->defaultValue; }
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Core\Driver\SQL\Column;
class DateTimeColumn extends Column {
public function __construct(string $name, bool $nullable = false, $defaultValue = NULL) {
parent::__construct($name, $nullable, $defaultValue);
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Core\Driver\SQL\Column;
class DoubleColumn extends NumericColumn {
public function __construct(string $name, bool $nullable, $defaultValue = NULL, ?int $totalDigits = null, ?int $decimalDigits = null) {
parent::__construct($name, $nullable, $defaultValue, $totalDigits, $decimalDigits);
$this->type = "DOUBLE";
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Core\Driver\SQL\Column;
class EnumColumn extends Column {
private array $values;
public function __construct(string $name, array $values, bool $nullable = false, $defaultValue = NULL) {
parent::__construct($name, $nullable, $defaultValue);
$this->values = $values;
}
public function addValue(string $value) {
$this->values[] = $value;
}
public function getValues(): array { return $this->values; }
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Core\Driver\SQL\Column;
class FloatColumn extends NumericColumn {
public function __construct(string $name, bool $nullable, $defaultValue = NULL, ?int $totalDigits = null, ?int $decimalDigits = null) {
parent::__construct($name, $nullable, $defaultValue, $totalDigits, $decimalDigits);
$this->type = "FLOAT";
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Core\Driver\SQL\Column;
class IntColumn extends Column {
protected string $type;
private bool $unsigned;
public function __construct(string $name, bool $nullable = false, $defaultValue = NULL, bool $unsigned = false) {
parent::__construct($name, $nullable, $defaultValue);
$this->type = "INTEGER";
$this->unsigned = $unsigned;
}
public function isUnsigned(): bool {
return $this->unsigned;
}
public function getType(): string {
return $this->type;
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Core\Driver\SQL\Column;
class JsonColumn extends Column {
public function __construct(string $name, bool $nullable = false, $defaultValue = null) {
parent::__construct($name, $nullable, $defaultValue);
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Core\Driver\SQL\Column;
use Core\Driver\SQL\Column\Column;
class NumericColumn extends Column {
protected string $type;
private ?int $totalDigits;
private ?int $decimalDigits;
public function __construct(string $name, bool $nullable, $defaultValue = NULL, ?int $totalDigits = null, ?int $decimalDigits = null) {
parent::__construct($name, $nullable, $defaultValue);
$this->totalDigits = $totalDigits;
$this->decimalDigits = $decimalDigits;
$this->type = "NUMERIC";
}
public function getDecimalDigits(): ?int {
return $this->decimalDigits;
}
public function getTotalDigits(): ?int {
return $this->totalDigits;
}
public function getTypeName(): string {
return $this->type;
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Core\Driver\SQL\Column;
class SerialColumn extends Column {
public function __construct(string $name, $defaultValue = NULL) {
parent::__construct($name, false, $defaultValue); # not nullable
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Core\Driver\SQL\Column;
class StringColumn extends Column {
private ?int $maxSize;
public function __construct(string $name, ?int $maxSize = null, bool $nullable = false, $defaultValue = null) {
parent::__construct($name, $nullable, $defaultValue);
$this->maxSize = $maxSize;
}
public function getMaxSize(): ?int { return $this->maxSize; }
}