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

MySQLReference   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A createInstance() 0 14 1
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\AbstractReference;
10
11
class MySQLReference extends AbstractReference
12
{
13
    /**
14
     * @param string $table
15
     * @param string $tablePrefix
16
     * @param array  $schema
17
     *
18
     * @return MySQLReference
19
     */
20
    public static function createInstance(string $table, string $tablePrefix, array $schema): self
21
    {
22
        $reference = new self($table, $tablePrefix, $schema['CONSTRAINT_NAME']);
23
24
        $reference->column = $schema['COLUMN_NAME'];
25
26
        $reference->foreignTable = $schema['REFERENCED_TABLE_NAME'];
27
        $reference->foreignKey = $schema['REFERENCED_COLUMN_NAME'];
28
29
        $reference->deleteRule = $schema['DELETE_RULE'];
30
        $reference->updateRule = $schema['UPDATE_RULE'];
31
32
        return $reference;
33
    }
34
}