Passed
Pull Request — master (#127)
by
unknown
06:05
created

ForeignKeys   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getForeignKey() 0 6 2
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