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

Column   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 24
c 1
b 0
f 0
dl 0
loc 54
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A null() 0 4 1
A check() 0 4 1
A defaultValue() 0 8 2
A comment() 0 4 1
A notNull() 0 4 1
A unique() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Migrations\V2;
6
7
class Column
8
{
9
    protected string $type;
10
    protected ?int $length = null;
11
    protected bool $isUnique = false;
12
    protected ?string $default = null;
13
    protected bool $isNotNull = false;
14
    protected ?string $check = null;
15
    protected ?string $comment = null;
16
17
    public function __construct(string $type, ?int $length = null)
18
    {
19
        $this->type = $type;
20
        $this->length = $length;
21
    }
22
23
    public function notNull(): self
24
    {
25
        $this->isNotNull = true;
26
        return $this;
27
    }
28
29
    public function null(): self
30
    {
31
        $this->isNotNull = false;
32
        return $this;
33
    }
34
35
    public function unique(): self
36
    {
37
        $this->isUnique = true;
38
        return $this;
39
    }
40
41
    public function check($check): self
42
    {
43
        $this->check = $check;
44
        return $this;
45
    }
46
47
    public function defaultValue(?string $default): self
48
    {
49
        if ($default === null) {
50
            $this->null();
51
        }
52
53
        $this->default = $default;
54
        return $this;
55
    }
56
57
    public function comment(?string $comment): self
58
    {
59
        $this->comment = $comment;
60
        return $this;
61
    }
62
}
63