Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
phpType method renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy-j committed Feb 21, 2019
1 parent 3066596 commit a31ed0c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/ColumnInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getName(): string;
*
* @return string
*/
public function getType(): string;
public function getInternalType(): string;

/**
* DBMS specific reverse mapping must map database specific type into limited set of abstract
Expand All @@ -49,7 +49,7 @@ public function getAbstractType(): string;
*
* @return string
*/
public function phpType(): string;
public function getType(): string;

/**
* Column size.
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Postgres/Schema/PostgresColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ private function normalizeDefault()
$this->defaultValue = (strtolower($this->defaultValue) == 'true');
}

if ($this->phpType() == self::FLOAT || $this->phpType() == self::INT) {
if ($this->getType() == self::FLOAT || $this->getType() == self::INT) {
if (preg_match('/^\(?(.*?)\)?(?!::(.+))?$/', $this->defaultValue, $matches)) {
//Negative numeric values
$this->defaultValue = $matches[1];
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/SQLServer/Schema/SQLServerColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ private function normalizeDefault()
}

if (
$this->phpType() != 'string'
$this->getType() != 'string'
&& ($this->defaultValue[0] == '(' && $this->defaultValue[strlen($this->defaultValue) - 1] == ')')
) {
//Cut another braces
Expand Down
14 changes: 7 additions & 7 deletions src/Schema/AbstractColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,15 @@ public function __construct(string $table, string $name, \DateTimeZone $timezone
/**
* {@inheritdoc}
*/
public function getType(): string
public function getInternalType(): string
{
return $this->type;
}

/**
* {@inheritdoc}
*/
public function phpType(): string
public function getType(): string
{
$schemaType = $this->getAbstractType();
foreach ($this->phpMapping as $phpType => $candidates) {
Expand Down Expand Up @@ -335,7 +335,7 @@ public function getDefaultValue()
return $this->formatDatetime($this->getAbstractType(), $this->defaultValue);
}

switch ($this->phpType()) {
switch ($this->getType()) {
case 'int':
return (int)$this->defaultValue;
case 'float':
Expand Down Expand Up @@ -619,7 +619,7 @@ public function __debugInfo()
'type' => [
'database' => $this->type,
'schema' => $this->getAbstractType(),
'php' => $this->phpType(),
'php' => $this->getType(),
],
];

Expand Down Expand Up @@ -722,15 +722,15 @@ protected function quoteDefault(DriverInterface $driver): string
return $defaultValue->sqlStatement();
}

if ($this->phpType() == 'bool') {
if ($this->getType() == 'bool') {
return $defaultValue ? 'TRUE' : 'FALSE';
}

if ($this->phpType() == 'float') {
if ($this->getType() == 'float') {
return sprintf('%F', $defaultValue);
}

if ($this->phpType() == 'int') {
if ($this->getType() == 'int') {
return strval($defaultValue);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Database/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ protected function assertSameAsInDB(AbstractTable $current)
protected function compareColumns(AbstractColumn $a, AbstractColumn $b)
{
$this->assertSame(
$a->getType(),
$b->getType(),
$a->getInternalType(),
$b->getInternalType(),
"Column {$a} type has been changed"
);

Expand Down
4 changes: 2 additions & 2 deletions tests/Database/Postgres/ConsistencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testPrimary()
$schema = $d->getSchema('table');
$this->assertTrue($schema->exists());

$this->assertSame($schema->column('target')->getType(), $column->getType());
$this->assertSame($schema->column('target')->getInternalType(), $column->getInternalType());

$this->assertInstanceOf(
FragmentInterface::class,
Expand Down Expand Up @@ -73,7 +73,7 @@ public function testBigPrimary()
$schema = $this->schema('table');
$this->assertTrue($schema->exists());

$this->assertSame($schema->column('target')->getType(), $column->getType());
$this->assertSame($schema->column('target')->getInternalType(), $column->getInternalType());

$this->assertInstanceOf(
FragmentInterface::class,
Expand Down

0 comments on commit a31ed0c

Please sign in to comment.