Passed
Push — master ( 03d3d0...cea9c0 )
by Alexander
07:36 queued 05:58
created

TableSchema   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 23
ccs 4
cts 4
cp 1
rs 10
wmc 2

2 Methods

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