Add   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 6
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\Column;
6
7
use Cycle\Migrations\CapsuleInterface;
8
use Cycle\Migrations\Exception\Operation\ColumnException;
9
10
final class Add extends Column
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 272
    public function execute(CapsuleInterface $capsule): void
16
    {
17 272
        $schema = $capsule->getSchema($this->getTable());
18
19 272
        if ($schema->hasColumn($this->name)) {
20 16
            throw new ColumnException(
21 16
                "Unable to create column '{$schema->getName()}'.'{$this->name}', column already exists"
22
            );
23
        }
24
25
        //Declaring column
26 264
        $this->declareColumn($schema);
27
    }
28
}
29