Passed
Pull Request — 3.x (#31)
by
unknown
11:39
created

ForeignKey::onUpdate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Migrations\V2;
6
7
class ForeignKey
8
{
9
    protected array $innerKeys = [];
10
    protected string $outerTable;
11
    protected array $outerKeys = [];
12
    protected FKAction $onDelete;
13
    protected FKAction $onUpdate;
14
    protected ?string $name = null;
15
16
    public function __construct(array $innerKey, string $table, array $outerKey)
17
    {
18
        $this->innerKeys = $innerKey;
19
        $this->outerTable = $table;
20
        $this->outerKeys = $outerKey;
21
22
        $this->onDelete = FKAction::cascade();
23
        $this->onUpdate = FKAction::cascade();
24
    }
25
26
    public function name(?string $name): self
27
    {
28
        $this->name = $name;
29
30
        return $this;
31
    }
32
33
    public function onDelete(FKAction $action): self
34
    {
35
        $this->onDelete = $action;
36
37
        return $this;
38
    }
39
40
    public function onUpdate(FKAction $action): self
41
    {
42
        $this->onUpdate = $action;
43
44
        return $this;
45
    }
46
}
47