Initial xentral_oss_20.3.c9ffacf
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Components\SchemaCreator\Index;
|
||||
|
||||
use Xentral\Components\SchemaCreator\Interfaces\IndexInterface;
|
||||
|
||||
final class Constraint implements IndexInterface
|
||||
{
|
||||
/** @var string $type */
|
||||
private $type = 'CONSTRAINT';
|
||||
|
||||
/** @var string $foreignKey */
|
||||
private $foreignKey;
|
||||
|
||||
/** @var string $parentTable */
|
||||
private $parentTable;
|
||||
|
||||
/** @var string $parentId */
|
||||
private $parentId;
|
||||
|
||||
/** @var array $cascadeOn */
|
||||
private $cascadeOn;
|
||||
|
||||
/** @var string $name */
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $foreignKey
|
||||
* @param string $parentTable
|
||||
* @param array $parentId
|
||||
* @param array $cascadeOn
|
||||
*/
|
||||
public function __construct(
|
||||
string $name,
|
||||
array $foreignKey,
|
||||
string $parentTable,
|
||||
array $parentId,
|
||||
array $cascadeOn = []
|
||||
) {
|
||||
$this->parentId = $parentId;
|
||||
$this->foreignKey = $foreignKey;
|
||||
$this->cascadeOn = $cascadeOn;
|
||||
$this->parentTable = $parentTable;
|
||||
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getParenId(): array
|
||||
{
|
||||
return $this->parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getParentTable(): string
|
||||
{
|
||||
return $this->parentTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCascadeOn(): array
|
||||
{
|
||||
return $this->cascadeOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getForeignKey(): array
|
||||
{
|
||||
return $this->foreignKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getReferences(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isUnique(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Components\SchemaCreator\Index;
|
||||
|
||||
use Xentral\Components\SchemaCreator\Interfaces\IndexInterface;
|
||||
|
||||
final class Fulltext implements IndexInterface
|
||||
{
|
||||
/** @var string $type */
|
||||
private $type = 'FULLTEXT';
|
||||
|
||||
/** @var string|null $name */
|
||||
private $name;
|
||||
|
||||
/** @var array $references */
|
||||
private $references;
|
||||
|
||||
/**
|
||||
* @param array $references
|
||||
* @param string|null $name
|
||||
*/
|
||||
public function __construct(array $references, ?string $name = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->references = $references;
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
if (empty($this->name)) {
|
||||
return 'fulltextkey_'.implode('_', array_map('strtolower', $this->references));
|
||||
}
|
||||
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getReferences(): array
|
||||
{
|
||||
return $this->references;
|
||||
}
|
||||
|
||||
public function isUnique(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Components\SchemaCreator\Index;
|
||||
|
||||
use Xentral\Components\SchemaCreator\Interfaces\IndexInterface;
|
||||
|
||||
final class Index implements IndexInterface
|
||||
{
|
||||
/** @var string $type */
|
||||
private $type = 'INDEX';
|
||||
|
||||
/** @var string|null $name */
|
||||
private $name;
|
||||
|
||||
/** @var array $references */
|
||||
private $references;
|
||||
|
||||
/**
|
||||
* @param array $references
|
||||
* @param string|null $name
|
||||
*/
|
||||
public function __construct(array $references, ?string $name = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->references = $references;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
if (empty($this->name)) {
|
||||
return 'index_'.implode('_', array_map('strtolower', $this->references));
|
||||
}
|
||||
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getReferences(): array
|
||||
{
|
||||
return $this->references;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isUnique(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Components\SchemaCreator\Index;
|
||||
|
||||
use Xentral\Components\SchemaCreator\Interfaces\PrimaryKeyInterface;
|
||||
use Xentral\Components\SchemaCreator\Interfaces\IndexInterface;
|
||||
|
||||
final class Primary implements IndexInterface, PrimaryKeyInterface
|
||||
{
|
||||
|
||||
/** @var string $type */
|
||||
private $type = 'PRIMARY KEY';
|
||||
|
||||
/** @var array $references */
|
||||
private $references;
|
||||
|
||||
/**
|
||||
* @param array $references
|
||||
*/
|
||||
public function __construct(array $references)
|
||||
{
|
||||
$this->references = $references;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'PRIMARY';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getReferences(): array
|
||||
{
|
||||
return $this->references;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isUnique(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Xentral\Components\SchemaCreator\Index;
|
||||
|
||||
use Xentral\Components\SchemaCreator\Interfaces\IndexInterface;
|
||||
use Xentral\Components\SchemaCreator\Interfaces\UniqueIndexInterface;
|
||||
|
||||
final class Unique implements IndexInterface, UniqueIndexInterface
|
||||
{
|
||||
/** @var string $type */
|
||||
private $type = UniqueIndexInterface::TYPE;
|
||||
|
||||
/** @var string|null $name */
|
||||
private $name;
|
||||
|
||||
/** @var array $references */
|
||||
private $references;
|
||||
|
||||
/**
|
||||
* @param array $references
|
||||
* @param string|null $name
|
||||
*/
|
||||
public function __construct(array $references, ?string $name = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->references = $references;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
if (empty($this->name)) {
|
||||
return 'unique_'.implode('_', array_map('strtolower', $this->references));
|
||||
}
|
||||
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getReferences(): array
|
||||
{
|
||||
return $this->references;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function isUnique(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user