Completed
Branch feature/pre-split (1fb805)
by Anton
03:35
created

SQlServerReference   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createInstance() 0 13 3
1
<?php
2
/**
3
 * components
4
 *
5
 * @author    Wolfy-J
6
 */
7
namespace Spiral\Database\Drivers\SQLServer\Schemas;
8
9
use Spiral\Database\Schemas\Prototypes\AbstractReference;
10
11
class SQlServerReference extends AbstractReference
12
{
13
    /**
14
     * @param string $table
15
     * @param string $tablePrefix
16
     * @param array  $schema
17
     *
18
     * @return SQlServerReference
19
     */
20
    public static function createInstance(string $table, string $tablePrefix, array $schema): self
21
    {
22
        $foreign = new self($table, $tablePrefix, $schema['FK_NAME']);
23
24
        $foreign->column = $schema['FKCOLUMN_NAME'];
25
        $foreign->foreignTable = $schema['PKTABLE_NAME'];
26
        $foreign->foreignKey = $schema['PKCOLUMN_NAME'];
27
28
        $foreign->deleteRule = $schema['DELETE_RULE'] ? self::NO_ACTION : self::CASCADE;
29
        $foreign->updateRule = $schema['UPDATE_RULE'] ? self::NO_ACTION : self::CASCADE;
30
31
        return $foreign;
32
    }
33
}