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

ColumnParser   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 10
eloc 16
c 1
b 0
f 0
dl 0
loc 55
rs 10

9 Methods

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