| Total Complexity | 9 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | trait TableIndexTrait |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @param array $row |
||
| 12 | * |
||
| 13 | * @return string |
||
| 14 | */ |
||
| 15 | private function getTableIndexType(array $row): string |
||
| 16 | { |
||
| 17 | $name = $row['Key_name']; |
||
| 18 | if ($name === 'PRIMARY') { |
||
| 19 | return 'PRIMARY'; |
||
| 20 | } |
||
| 21 | if ($row['Index_type'] === 'FULLTEXT') { |
||
| 22 | return 'FULLTEXT'; |
||
| 23 | } |
||
| 24 | if (!$row['Non_unique']) { |
||
| 25 | return 'UNIQUE'; |
||
| 26 | } |
||
| 27 | if ($row['Index_type'] === 'SPATIAL') { |
||
| 28 | return 'SPATIAL'; |
||
| 29 | } |
||
| 30 | return 'INDEX'; |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param array $row |
||
| 35 | * |
||
| 36 | * @return IndexEntity |
||
| 37 | */ |
||
| 38 | private function makeTableIndex(array $row): IndexEntity |
||
| 39 | { |
||
| 40 | $index = new IndexEntity(); |
||
| 41 | |||
| 42 | $index->type = $this->getTableIndexType($row); |
||
| 43 | $index->columns[] = $row['Column_name']; |
||
| 44 | $index->lengths[] = ($row['Index_type'] == 'SPATIAL' ? null : $row['Sub_part']); |
||
| 45 | $index->descs[] = null; |
||
| 46 | |||
| 47 | return $index; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @inheritDoc |
||
| 52 | */ |
||
| 53 | public function indexes(string $table, ConnectionInterface $connection = null) |
||
| 60 | } |
||
| 61 | } |
||
| 62 |