Passed
Push — master ( 2d168f...0cc03e )
by Wilmer
12:04 queued 10:25
created

TableSchema   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 29
ccs 7
cts 7
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A foreignKeys() 0 3 1
A foreignKey() 0 3 1
A getForeignKeys() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Mysql;
6
7
use Yiisoft\Db\Schema\TableSchema as AbstractTableSchema;
8
9
final class TableSchema extends AbstractTableSchema
10
{
11
    private array $foreignKeys = [];
12
13
    /**
14
     * @return array foreign keys of this table. Each array element is of the following structure:
15
     *
16
     * ```php
17
     * [
18
     *  'ForeignTableName',
19
     *  'fk1' => 'pk1',  // pk1 is in foreign table
20
     *  'fk2' => 'pk2',  // if composite foreign key
21
     * ]
22
     * ```
23
     */
24 1
    public function getForeignKeys(): array
25
    {
26 1
        return $this->foreignKeys;
27
    }
28
29
30 24
    public function foreignKey(string $id, array $to): void
31
    {
32 24
        $this->foreignKeys[$id] = $to;
33 24
    }
34
35 77
    public function foreignKeys(array $value): void
36
    {
37 77
        $this->foreignKeys = $value;
38 77
    }
39
}
40