Total Complexity | 4 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
14 | trait TForeignKey |
||
15 | { |
||
16 | /** @var array<string, ForeignKey> */ |
||
17 | protected $foreignKeys = []; |
||
18 | /** @var ForeignKey|null */ |
||
19 | private $foreignKeyClass = null; |
||
20 | |||
21 | 7 | public function addForeignKey(string $localAlias, string $remoteRecord, string $localEntryKey, string $remoteEntryKey): void |
|
22 | { |
||
23 | 7 | $this->initClassFks(); |
|
24 | 7 | $foreignKeyClass = clone $this->foreignKeyClass; |
|
25 | 7 | $this->foreignKeys[$localAlias] = $foreignKeyClass->setData($localAlias, $remoteRecord, $localEntryKey, $remoteEntryKey); |
|
26 | } |
||
27 | |||
28 | 7 | private function initClassFks(): void |
|
29 | { |
||
30 | 7 | if (empty($this->foreignKeyClass)) { |
|
31 | 7 | $this->foreignKeyClass = new ForeignKey(); |
|
32 | } |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @return array<string, ForeignKey> |
||
37 | */ |
||
38 | 11 | public function getForeignKeys(): array |
|
41 | } |
||
42 | } |
||
43 |