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

Commit

Permalink
- minor inspection driven improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy-j committed Nov 21, 2019
1 parent fc53c15 commit e3de3c3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
12 changes: 7 additions & 5 deletions src/Schema/AbstractColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -781,12 +781,14 @@ protected function formatDatetime(string $type, $value)

if ($value instanceof \DateTimeInterface) {
$datetime = clone $value;
} elseif (is_numeric($value)) {
//Presumably timestamp
$datetime = new \DateTime('now', $this->timezone);
$datetime->setTimestamp($value);
} else {
$datetime = new \DateTime($value, $this->timezone);
if (is_numeric($value)) {
//Presumably timestamp
$datetime = new \DateTime('now', $this->timezone);
$datetime->setTimestamp($value);
} else {
$datetime = new \DateTime($value, $this->timezone);
}
}

switch ($type) {
Expand Down
9 changes: 6 additions & 3 deletions src/Schema/AbstractTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public function getInitialName(): string
*/
public function declareDropped(): void
{
if ($this->status == self::STATUS_NEW) {
if ($this->status === self::STATUS_NEW) {
throw new SchemaException('Unable to drop non existed table');
}

Expand Down Expand Up @@ -668,8 +668,11 @@ public function save(int $operation = HandlerInterface::DO_ALL, bool $reset = tr
if ($this->status === self::STATUS_NEW) {
//Executing table creation
$handler->createTable($prepared);
} elseif ($this->hasChanges()) {
$handler->syncTable($prepared, $operation);
} else {
//Executing table syncing
if ($this->hasChanges()) {
$handler->syncTable($prepared, $operation);
}
}

// Syncing our schemas
Expand Down
6 changes: 3 additions & 3 deletions src/Schema/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function registerForeignKey(AbstractForeignKey $reference): void
public function forgetColumn(AbstractColumn $column): State
{
foreach ($this->columns as $name => $columnSchema) {
if ($columnSchema === $column) {
if ($columnSchema == $column) {
unset($this->columns[$name]);
break;
}
Expand All @@ -210,7 +210,7 @@ public function forgetColumn(AbstractColumn $column): State
public function forgetIndex(AbstractIndex $index): void
{
foreach ($this->indexes as $name => $indexSchema) {
if ($indexSchema === $index) {
if ($indexSchema == $index) {
unset($this->indexes[$name]);
break;
}
Expand All @@ -225,7 +225,7 @@ public function forgetIndex(AbstractIndex $index): void
public function forgerForeignKey(AbstractForeignKey $foreignKey): void
{
foreach ($this->foreignKeys as $name => $foreignSchema) {
if ($foreignSchema === $foreignKey) {
if ($foreignSchema == $foreignKey) {
unset($this->foreignKeys[$name]);
break;
}
Expand Down

0 comments on commit e3de3c3

Please sign in to comment.