Passed
Push — master ( d42673...c7102b )
by Wilmer
09:45 queued 08:06
created

TableSchema   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 33
ccs 8
cts 10
cp 0.8
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A foreignKey() 0 3 1
A getForeignKeys() 0 3 1
A compositeFK() 0 3 1
A foreignKeys() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Sqlite\Schema;
6
7
use Yiisoft\Db\Schema\TableSchema as AbstractTableSchema;
8
9
/**
10
 * TableSchema represents the metadata of a database table.
11
 *
12
 * @property array $columnNames List of column names. This property is read-only.
13
 */
14
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 5
    public function getForeignKeys(): array
30
    {
31 5
        return $this->foreignKeys;
32
    }
33
34 5
    public function compositeFK(int $id, string $from, string $to): void
35
    {
36 5
        $this->foreignKeys[$id][$from] = $to;
37 5
    }
38
39 5
    public function foreignKey(int $id, array $to): void
40
    {
41 5
        $this->foreignKeys[$id] = $to;
42 5
    }
43
44
    public function foreignKeys(array $value): void
45
    {
46
        $this->foreignKeys = $value;
47
    }
48
}
49