Drop   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 17
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Migrations\Operation\Index;
6
7
use Cycle\Migrations\CapsuleInterface;
8
use Cycle\Migrations\Exception\Operation\IndexException;
9
10
final class Drop extends Index
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 40
    public function execute(CapsuleInterface $capsule): void
16
    {
17 40
        $schema = $capsule->getSchema($this->getTable());
18
19 40
        if (!$schema->hasIndex($this->columns)) {
20 8
            $columns = implode(',', $this->columns);
21 8
            throw new IndexException(
22 8
                "Unable to drop index '{$schema->getName()}'.({$columns}), index does not exists"
23
            );
24
        }
25
26 32
        $schema->dropIndex($this->columns);
27
    }
28
}
29