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

MySQLReference::createInstance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 3
dl 0
loc 14
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\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
}