Update::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 12
ccs 7
cts 7
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\Table;
6
7
use Cycle\Database\Driver\HandlerInterface;
8
use Cycle\Migrations\CapsuleInterface;
9
use Cycle\Migrations\Exception\Operation\TableException;
10
use Cycle\Migrations\Operation\AbstractOperation;
11
12
final class Update extends AbstractOperation
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 120
    public function execute(CapsuleInterface $capsule): void
18
    {
19 120
        $schema = $capsule->getSchema($this->getTable());
20 120
        $database = $this->database ?? '[default]';
0 ignored issues
show
Bug Best Practice introduced by
The property database does not exist on Cycle\Migrations\Operation\Table\Update. Did you maybe forget to declare it?
Loading history...
21
22 120
        if (!$schema->exists()) {
23 8
            throw new TableException(
24 8
                "Unable to update table '{$database}'.'{$this->getTable()}', no table exists"
25
            );
26
        }
27
28 112
        $schema->save(HandlerInterface::DO_ALL);
29
    }
30
}
31