Passed
Pull Request — master (#81)
by Wilmer
10:46
created

TableSchema::getForeignKeys()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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 ?string $comment = null;
17
    private array $foreignKeys = [];
18
19 2
    public function getComment(): ?string
20
    {
21 2
        return $this->comment;
22
    }
23
24
    /**
25
     * @return array foreign keys of this table. Each array element is of the following structure:
26
     *
27
     * ```php
28
     * [
29
     *  'ForeignTableName',
30
     *  'fk1' => 'pk1',  // pk1 is in foreign table
31
     *  'fk2' => 'pk2',  // if composite foreign key
32
     * ]
33
     * ```
34
     */
35 1
    public function getForeignKeys(): array
36
    {
37 1
        return $this->foreignKeys;
38
    }
39
40 154
    public function comment(?string $comment): void
41
    {
42 154
        $this->comment = $comment;
43 154
    }
44
45 9
    public function foreignKey(string $id, array $to): void
46
    {
47 9
        $this->foreignKeys[$id] = $to;
48 9
    }
49
}
50