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

MySQLIndex   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 52.38 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 11
loc 21
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A createInstance() 11 11 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}