Completed
Push — master ( 2dbe32...7984fa )
by David
18s queued 10s
created

ForeignKeys::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
4
namespace TheCodingMachine\TDBM\Schema;
5
6
7
class ForeignKeys
8
{
9
    /**
10
     * @var array
11
     */
12
    private $foreignKeys;
13
14
    /**
15
     * @var array
16
     */
17
    private $foreignKey;
18
19
    /**
20
     * @param array<string, array<string, string|array<string>>> $foreignKeys
21
     */
22
    public function __construct(array $foreignKeys)
23
    {
24
        $this->foreignKeys = $foreignKeys;
25
        $this->foreignKey = [];
26
    }
27
28
    public function getForeignKey(string $fkName): ForeignKey
29
    {
30
        if (!isset($this->foreignKey[$fkName])) {
31
            $this->foreignKey[$fkName] = new ForeignKey($this->foreignKeys[$fkName]);
32
        }
33
        return $this->foreignKey[$fkName];
34
    }
35
36
}
37