Conditions | 3 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
24 | 184 | public function execute(CapsuleInterface $capsule): void |
|
25 | { |
||
26 | 184 | $schema = $capsule->getSchema($this->getTable()); |
|
27 | |||
28 | 184 | if ($schema->hasIndex($this->columns)) { |
|
29 | 8 | $columns = implode(',', $this->columns); |
|
30 | 8 | throw new IndexException( |
|
31 | 8 | "Unable to create index '{$schema->getName()}'.({$columns}), index already exists" |
|
32 | ); |
||
33 | } |
||
34 | |||
35 | 184 | $schema->index($this->columns)->unique( |
|
36 | 184 | $this->getOption('unique', false) |
|
37 | ); |
||
38 | |||
39 | 184 | if ($this->hasOption('name')) { |
|
40 | 112 | $schema->index($this->columns)->setName($this->getOption('name')); |
|
41 | } |
||
44 |