Passed
Pull Request — master (#32)
by Wilmer
29:12 queued 14:12
created

PgsqlTableSchema::foreignKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Pgsql\Schema;
6
7
use Yiisoft\Db\Schema\TableSchema as AbstractTableSchema;
8
9
final class PgsqlTableSchema 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
    public function getForeignKeys(): array
25
    {
26
        return $this->foreignKeys;
27
    }
28
29
    public function foreignKey(string $id, array $to): void
30
    {
31
        $this->foreignKeys[$id] = $to;
32
    }
33
34
    public function foreignKeys(array $value): void
35
    {
36
        $this->foreignKeys = $value;
37
    }
38
}
39