Passed
Push — master ( 10a192...087136 )
by Aleksei
07:38 queued 05:42
created

Alter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 17
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 12 2
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license MIT
7
 * @author  Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Cycle\Migrations\Operation\Column;
13
14
use Cycle\Migrations\CapsuleInterface;
15
use Cycle\Migrations\Exception\Operation\ColumnException;
16
17
final class Alter extends Column
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function execute(CapsuleInterface $capsule): void
23
    {
24
        $schema = $capsule->getSchema($this->getTable());
25
26
        if (!$schema->hasColumn($this->name)) {
27
            throw new ColumnException(
28
                "Unable to alter column '{$schema->getName()}'.'{$this->name}', column does not exists"
29
            );
30
        }
31
32
        //Declaring column change
33
        $this->declareColumn($schema);
34
    }
35
}
36