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 6
cts 6
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\ForeignKey;
6
7
use Cycle\Migrations\CapsuleInterface;
8
use Cycle\Migrations\Exception\Operation\ForeignKeyException;
9
10
final class Drop extends ForeignKey
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 24
    public function execute(CapsuleInterface $capsule): void
16
    {
17 24
        $schema = $capsule->getSchema($this->getTable());
18
19 24
        if (!$schema->hasForeignKey($this->columns)) {
20 8
            throw new ForeignKeyException(
21 8
                "Unable to drop foreign key '{$schema->getName()}'.'{$this->columnNames()}', "
22
                . 'foreign key does not exists'
23
            );
24
        }
25
26 16
        $schema->dropForeignKey($this->columns);
27
    }
28
}
29