Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
22 | 24 | public function execute(CapsuleInterface $capsule): void |
|
23 | { |
||
24 | 24 | $schema = $capsule->getSchema($this->getTable()); |
|
25 | 24 | $database = $this->database ?? '[default]'; |
|
|
|||
26 | |||
27 | 24 | if (!$schema->exists()) { |
|
28 | 8 | throw new TableException( |
|
29 | 8 | "Unable to rename table '{$database}'.'{$this->getTable()}', table does not exists" |
|
30 | ); |
||
31 | } |
||
32 | |||
33 | 16 | if ($capsule->getDatabase()->hasTable($this->newName)) { |
|
34 | 8 | throw new TableException( |
|
35 | 8 | "Unable to rename table '{$database}'.'{$this->getTable()}', table '{$this->newName}' already exists" |
|
36 | ); |
||
37 | } |
||
38 | |||
39 | 8 | $schema->setName($this->newName); |
|
40 | 8 | $schema->save(HandlerInterface::DO_ALL); |
|
41 | } |
||
43 |