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

ColumnTrait   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 13
eloc 18
c 1
b 0
f 0
dl 0
loc 71
rs 10

13 Methods

Rating   Name   Duplication   Size   Complexity  
A boolean() 0 3 1
A bigInteger() 0 3 1
A numeric() 0 3 1
A point() 0 3 1
A text() 0 3 1
A dateTime() 0 3 1
A integer() 0 3 1
A json() 0 3 1
A customType() 0 3 1
A string() 0 3 1
A money() 0 3 1
A bigPrimaryKey() 0 6 1
A primaryKey() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Migrations\V2;
6
7
trait ColumnTrait
8
{
9
    protected function primaryKey($length = null): Column
10
    {
11
        $column = new Column(ColumnType::TYPE_PK, $length);
12
        $column->notNull();
13
14
        return $column;
15
    }
16
17
    protected function bigPrimaryKey($length = null): Column
18
    {
19
        $column = new Column(ColumnType::TYPE_BIGPK, $length);
20
        $column->notNull();
21
22
        return $column;
23
    }
24
25
    protected function string($length = null): Column
26
    {
27
        return new Column(ColumnType::TYPE_STRING, $length);
28
    }
29
30
    protected function text(): Column
31
    {
32
        return new Column(ColumnType::TYPE_TEXT);
33
    }
34
35
    protected function integer($length = null): Column
36
    {
37
        return new Column(ColumnType::TYPE_INTEGER, $length);
38
    }
39
40
    protected function bigInteger($length = null): Column
41
    {
42
        return new Column(ColumnType::TYPE_BIGINT, $length);
43
    }
44
45
    protected function numeric($precision = null): Column
46
    {
47
        return new Column(ColumnType::TYPE_NUMERIC, $precision);
48
    }
49
50
    protected function dateTime(): Column
51
    {
52
        return new Column(ColumnType::TYPE_DATETIME);
53
    }
54
55
    protected function boolean(): Column
56
    {
57
        return new Column(ColumnType::TYPE_BOOLEAN);
58
    }
59
60
    protected function money(): Column
61
    {
62
        return new Column(ColumnType::TYPE_MONEY);
63
    }
64
65
    protected function json(): Column
66
    {
67
        return new Column(ColumnType::TYPE_JSON);
68
    }
69
70
    protected function point(): Column
71
    {
72
        return new Column(ColumnType::TYPE_POINT);
73
    }
74
75
    protected function customType(string $type): Column
76
    {
77
        return new Column($type);
78
    }
79
}
80