| Conditions | 4 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | public static function createInstance(string $table, array $schema): self |
||
| 20 | { |
||
| 21 | $index = new self($table, $schema['indexname']); |
||
| 22 | $index->type = strpos($schema['indexdef'], ' UNIQUE ') ? self::UNIQUE : self::NORMAL; |
||
| 23 | |||
| 24 | if (preg_match('/\(([^)]+)\)/', $schema['indexdef'], $matches)) { |
||
| 25 | $columns = explode(',', $matches[1]); |
||
| 26 | |||
| 27 | foreach ($columns as $column) { |
||
| 28 | //Postgres adds quotes to all columns with uppercase letters |
||
| 29 | $index->columns[] = trim($column, ' "\''); |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 33 | return $index; |
||
| 34 | } |
||
| 35 | } |