Alter::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Migrations\Operation\Column;
6
7
use Cycle\Migrations\CapsuleInterface;
8
use Cycle\Migrations\Exception\Operation\ColumnException;
9
10
final class Alter extends Column
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 56
    public function execute(CapsuleInterface $capsule): void
16
    {
17 56
        $schema = $capsule->getSchema($this->getTable());
18
19 56
        if (!$schema->hasColumn($this->name)) {
20 8
            throw new ColumnException(
21 8
                "Unable to alter column '{$schema->getName()}'.'{$this->name}', column does not exists"
22
            );
23
        }
24
25
        //Declaring column change
26 48
        $this->declareColumn($schema);
27
    }
28
}
29