Blueprint   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 131
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 131
rs 10
c 0
b 0
f 0
wmc 12

11 Methods

Rating   Name   Duplication   Size   Complexity  
A text() 0 5 1
A string() 0 5 1
A getQuery() 0 5 1
A timestamp() 0 5 1
A setValueTypeRow() 0 3 2
A float() 0 5 1
A integer() 0 5 1
A boolean() 0 5 1
A datetime() 0 5 1
A id() 0 5 1
A bigInt() 0 5 1
1
<?php
2
3
namespace Luke\Types;
4
5
6
class Blueprint implements IBlueprint
7
{
8
    use SubjectAction;
9
10
    private string $query = '';
11
12
    /**
13
     * Undocumented function
14
     *
15
     * @return static
16
     */
17
    public function id(): static
18
    {
19
        $this->bigint('id')->unsigned()->notNull()->primaryKey();
20
21
        return $this;
22
    }
23
24
    public function getQuery()
25
    {
26
        $value = ltrim($this->query,$this->query[0]);
27
28
        return $value;
29
    }
30
31
    /**
32
     * Undocumented function
33
     *
34
     * @param string $name
35
     * @param integer $limit
36
     * @return static
37
     */
38
    public function string(string $name, int $limit = 255): static
39
    {
40
        $this->setValueTypeRow($name, "varchar(" . $limit . ")");
41
42
        return $this;
43
    }
44
45
    /**
46
     * Undocumented function
47
     *
48
     * @param string $name
49
     * @return static
50
     */
51
    public function integer(string $name): static
52
    {
53
        $this->setValueTypeRow($name, "INT");
54
55
        return $this;
56
    }
57
58
    /**
59
     * Undocumented function
60
     *
61
     * @param string $name
62
     * @return static
63
     */
64
    public function timestamp(string $name): static
65
    {
66
        $this->setValueTypeRow($name, "timestamp");
67
68
        return $this;
69
    }
70
71
    /**
72
     * Undocumented function
73
     *
74
     * @param string $name
75
     * @return static
76
     */
77
    public function bigInt(string $name): static
78
    {
79
        $this->setValueTypeRow($name, "bigInt");
80
81
        return $this;
82
    }
83
84
    /**
85
     * Undocumented function
86
     *
87
     * @param string $name
88
     * @return static
89
     */
90
    public function datetime(string $name): static
91
    {
92
        $this->setValueTypeRow($name, "datetime");
93
94
        return $this;
95
    }
96
97
    /**
98
     * @param string $name
99
     * @return static
100
     */
101
    public function float(string $name): static
102
    {
103
        $this->setValueTypeRow($name, "FLOAT");
104
105
        return $this;
106
    }
107
108
    /**
109
     * Undocumented function
110
     *
111
     * @param string $name
112
     * @return static
113
     */
114
    public function text(string $name): static
115
    {
116
        $this->setValueTypeRow($name, "TEXT");
117
118
        return $this;
119
    }
120
121
    /**
122
     * Undocumented function
123
     *
124
     * @param string $name
125
     * @return static
126
     */
127
    public function boolean(string $name): static
128
    {
129
        $this->setValueTypeRow($name, "BOOLEAN");
130
131
        return $this;
132
    }
133
134
    private function setValueTypeRow($value, string $query)
135
    {
136
        $this->query .= $value ? ",`$value` $query" : " $query";
137
    }
138
}
139