Passed
Push — 2.x ( b9b47b...d5b1be )
by Aleksei
20:07
created

MySQLForeignKey::hasIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of Cycle ORM package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Cycle\Database\Driver\MySQL\Schema;
13
14
use Cycle\Database\Schema\AbstractForeignKey;
15
16
class MySQLForeignKey extends AbstractForeignKey
17
{
18
    /**
19
     * @param string $table
20
     * @param string $tablePrefix
21
     * @param array  $schema
22
     *
23
     * @return MySQLForeignKey
24
     */
25 56
    public static function createInstance(string $table, string $tablePrefix, array $schema): self
26
    {
27 56
        $reference = new self($table, $tablePrefix, $schema['CONSTRAINT_NAME']);
28
29 56
        $reference->columns = $schema['COLUMN_NAME'];
30 56
        $reference->foreignTable = $schema['REFERENCED_TABLE_NAME'];
31 56
        $reference->foreignKeys = $schema['REFERENCED_COLUMN_NAME'];
32
33 56
        $reference->deleteRule = $schema['DELETE_RULE'];
34 56
        $reference->updateRule = $schema['UPDATE_RULE'];
35
36 56
        return $reference;
37
    }
38
39
    public function hasIndex(): bool
40
    {
41
        return true;
42
    }
43
}
44