Completed
Branch feature/pre-split (b5c37f)
by Anton
03:43
created

MySQLIndex::createInstance()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 3
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * components
4
 *
5
 * @author    Wolfy-J
6
 */
7
namespace Spiral\Database\Drivers\MySQL\Schemas;
8
9
use Spiral\Database\Schemas\Prototypes\AbstractIndex;
10
11
class MySQLIndex extends AbstractIndex
12
{
13
    /**
14
     * @param string $table
15
     * @param string $name
16
     * @param array  $schema
17
     *
18
     * @return MySQLIndex
19
     */
20 View Code Duplication
    public static function createInstance(string $table, string $name, array $schema): self
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
    {
22
        $index = new self($table, $name);
23
24
        foreach ($schema as $definition) {
25
            $index->type = $definition['Non_unique'] ? self::NORMAL : self::UNIQUE;
26
            $index->columns[] = $definition['Column_name'];
27
        }
28
29
        return $index;
30
    }
31
}