Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
17 | 256 | public function execute(CapsuleInterface $capsule): void |
|
18 | { |
||
19 | 256 | $schema = $capsule->getSchema($this->getTable()); |
|
20 | 256 | $database = $this->database ?? '[default]'; |
|
|
|||
21 | |||
22 | 256 | if ($schema->exists()) { |
|
23 | 16 | throw new TableException( |
|
24 | 16 | "Unable to create table '{$database}'.'{$this->getTable()}', table already exists" |
|
25 | ); |
||
26 | } |
||
27 | |||
28 | 248 | if (empty($schema->getColumns())) { |
|
29 | 8 | throw new TableException( |
|
30 | 8 | "Unable to create table '{$database}'.'{$this->getTable()}', no columns were added" |
|
31 | ); |
||
32 | } |
||
33 | |||
34 | 240 | $schema->save(HandlerInterface::DO_ALL); |
|
35 | } |
||
37 |