Code Duplication    Length = 19-20 lines in 2 locations

source/Spiral/Migrations/Operations/Table/DropTable.php 1 location

@@ 15-34 (lines=20) @@
12
use Spiral\Migrations\Exceptions\Operations\TableException;
13
use Spiral\Migrations\Operations\TableOperation;
14
15
class DropTable extends TableOperation
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function execute(CapsuleInterface $capsule)
21
    {
22
        $schema = $capsule->getSchema($this->getDatabase(), $this->getTable());
23
        $database = $this->database ?? '[default]';
24
25
        if (!$schema->exists()) {
26
            throw new TableException(
27
                "Unable to drop table '{$database}'.'{$this->getTable()}', table does not exists"
28
            );
29
        }
30
31
        $schema->declareDropped();
32
        $schema->save(AbstractHandler::DO_ALL);
33
    }
34
}

source/Spiral/Migrations/Operations/Table/UpdateTable.php 1 location

@@ 15-33 (lines=19) @@
12
use Spiral\Migrations\Exceptions\Operations\TableException;
13
use Spiral\Migrations\Operations\TableOperation;
14
15
class UpdateTable extends TableOperation
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function execute(CapsuleInterface $capsule)
21
    {
22
        $schema = $capsule->getSchema($this->getDatabase(), $this->getTable());
23
        $database = $this->database ?? '[default]';
24
25
        if (!$schema->exists()) {
26
            throw new TableException(
27
                "Unable to update table '{$database}'.'{$this->getTable()}', no table exists"
28
            );
29
        }
30
31
        $schema->save(AbstractHandler::DO_ALL);
32
    }
33
}