Code Duplication    Length = 19-19 lines in 2 locations

source/Spiral/Migrations/Operations/Indexes/DropIndex.php 1 location

@@ 14-32 (lines=19) @@
11
use Spiral\Migrations\Exceptions\Operations\IndexException;
12
use Spiral\Migrations\Operations\IndexOperation;
13
14
class DropIndex extends IndexOperation
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function execute(CapsuleInterface $capsule)
20
    {
21
        $schema = $capsule->getSchema($this->getDatabase(), $this->getTable());
22
23
        if (!$schema->hasIndex($this->columns)) {
24
            $columns = join(',', $this->columns);
25
            throw new IndexException(
26
                "Unable to drop index '{$schema->getName()}'.({$columns}), index does not exists"
27
            );
28
        }
29
30
        $schema->dropIndex($this->columns);
31
    }
32
}

source/Spiral/Migrations/Operations/References/DropReference.php 1 location

@@ 14-32 (lines=19) @@
11
use Spiral\Migrations\Exceptions\Operations\ReferenceException;
12
use Spiral\Migrations\Operations\ReferenceOperation;
13
14
class DropReference extends ReferenceOperation
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function execute(CapsuleInterface $capsule)
20
    {
21
        $schema = $capsule->getSchema($this->getDatabase(), $this->getTable());
22
23
        if (!$schema->hasForeign($this->column)) {
24
            throw new ReferenceException(
25
                "Unable to drop foreign key '{$schema->getName()}'.'{$this->column}', "
26
                . "foreign key does not exists"
27
            );
28
        }
29
30
        $schema->dropForeign($this->column);
31
    }
32
}