Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
39 / 39 |
|
100.00% |
39 / 39 |
CRAP | |
100.00% |
1 / 1 |
ColumnDefinition | |
100.00% |
39 / 39 |
|
100.00% |
39 / 39 |
39 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
int | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
bigint | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
tinyint | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
decimal | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
float | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
mediumint | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
smallint | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
boolean | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
varchar | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
char | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
enum | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
set | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
text | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
longtext | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
mediumtext | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
tinytext | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
json | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
blob | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
tinyblob | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
mediumblob | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
longblob | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
bit | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
binary | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
varbinary | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
date | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
time | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
datetime | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
timestamp | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
year | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
geometrycollection | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
geometry | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
linestring | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
multilinestring | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
multipoint | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
multipolygon | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
point | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
polygon | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
sql | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php declare(strict_types=1); |
2 | /* |
3 | * This file is part of Aplus Framework Database Library. |
4 | * |
5 | * (c) Natan Felles <natanfelles@gmail.com> |
6 | * |
7 | * For the full copyright and license information, please view the LICENSE |
8 | * file that was distributed with this source code. |
9 | */ |
10 | namespace Framework\Database\Definition\Table\Columns; |
11 | |
12 | use Framework\Database\Database; |
13 | use Framework\Database\Definition\Table\Columns\DateTime\DateColumn; |
14 | use Framework\Database\Definition\Table\Columns\DateTime\DatetimeColumn; |
15 | use Framework\Database\Definition\Table\Columns\DateTime\TimeColumn; |
16 | use Framework\Database\Definition\Table\Columns\DateTime\TimestampColumn; |
17 | use Framework\Database\Definition\Table\Columns\DateTime\YearColumn; |
18 | use Framework\Database\Definition\Table\Columns\Geometry\GeometryCollectionColumn; |
19 | use Framework\Database\Definition\Table\Columns\Geometry\GeometryColumn; |
20 | use Framework\Database\Definition\Table\Columns\Geometry\LinestringColumn; |
21 | use Framework\Database\Definition\Table\Columns\Geometry\MultilinestringColumn; |
22 | use Framework\Database\Definition\Table\Columns\Geometry\MultipointColumn; |
23 | use Framework\Database\Definition\Table\Columns\Geometry\MultipolygonColumn; |
24 | use Framework\Database\Definition\Table\Columns\Geometry\PointColumn; |
25 | use Framework\Database\Definition\Table\Columns\Geometry\PolygonColumn; |
26 | use Framework\Database\Definition\Table\Columns\Numeric\BigintColumn; |
27 | use Framework\Database\Definition\Table\Columns\Numeric\BitColumn; |
28 | use Framework\Database\Definition\Table\Columns\Numeric\BooleanColumn; |
29 | use Framework\Database\Definition\Table\Columns\Numeric\DecimalColumn; |
30 | use Framework\Database\Definition\Table\Columns\Numeric\FloatColumn; |
31 | use Framework\Database\Definition\Table\Columns\Numeric\IntColumn; |
32 | use Framework\Database\Definition\Table\Columns\Numeric\MediumintColumn; |
33 | use Framework\Database\Definition\Table\Columns\Numeric\SmallintColumn; |
34 | use Framework\Database\Definition\Table\Columns\Numeric\TinyintColumn; |
35 | use Framework\Database\Definition\Table\Columns\String\BinaryColumn; |
36 | use Framework\Database\Definition\Table\Columns\String\BlobColumn; |
37 | use Framework\Database\Definition\Table\Columns\String\CharColumn; |
38 | use Framework\Database\Definition\Table\Columns\String\EnumColumn; |
39 | use Framework\Database\Definition\Table\Columns\String\JsonColumn; |
40 | use Framework\Database\Definition\Table\Columns\String\LongblobColumn; |
41 | use Framework\Database\Definition\Table\Columns\String\LongtextColumn; |
42 | use Framework\Database\Definition\Table\Columns\String\MediumblobColumn; |
43 | use Framework\Database\Definition\Table\Columns\String\MediumtextColumn; |
44 | use Framework\Database\Definition\Table\Columns\String\SetColumn; |
45 | use Framework\Database\Definition\Table\Columns\String\TextColumn; |
46 | use Framework\Database\Definition\Table\Columns\String\TinyblobColumn; |
47 | use Framework\Database\Definition\Table\Columns\String\TinytextColumn; |
48 | use Framework\Database\Definition\Table\Columns\String\VarbinaryColumn; |
49 | use Framework\Database\Definition\Table\Columns\String\VarcharColumn; |
50 | use Framework\Database\Definition\Table\DefinitionPart; |
51 | |
52 | /** |
53 | * Class ColumnDefinition. |
54 | * |
55 | * @see https://mariadb.com/kb/en/create-table/#index-definitions |
56 | * |
57 | * @package database |
58 | */ |
59 | class ColumnDefinition extends DefinitionPart |
60 | { |
61 | protected Database $database; |
62 | protected Column $column; |
63 | |
64 | public function __construct(Database $database) |
65 | { |
66 | $this->database = $database; |
67 | } |
68 | |
69 | public function int(int $maximum = null) : IntColumn |
70 | { |
71 | return $this->column = new IntColumn($this->database, $maximum); |
72 | } |
73 | |
74 | public function bigint(int $maximum = null) : BigintColumn |
75 | { |
76 | return $this->column = new BigintColumn($this->database, $maximum); |
77 | } |
78 | |
79 | public function tinyint(int $maximum = null) : TinyintColumn |
80 | { |
81 | return $this->column = new TinyintColumn($this->database, $maximum); |
82 | } |
83 | |
84 | public function decimal(int $maximum = null, int $decimals = null) : DecimalColumn |
85 | { |
86 | return $this->column = new DecimalColumn($this->database, $maximum, $decimals); |
87 | } |
88 | |
89 | public function float(int $maximum = null, int $decimals = null) : FloatColumn |
90 | { |
91 | return $this->column = new FloatColumn($this->database, $maximum, $decimals); |
92 | } |
93 | |
94 | public function mediumint(int $maximum = null) : MediumintColumn |
95 | { |
96 | return $this->column = new MediumintColumn($this->database, $maximum); |
97 | } |
98 | |
99 | public function smallint(int $maximum = null) : SmallintColumn |
100 | { |
101 | return $this->column = new SmallintColumn($this->database, $maximum); |
102 | } |
103 | |
104 | public function boolean(int $maximum = null) : BooleanColumn |
105 | { |
106 | return $this->column = new BooleanColumn($this->database, $maximum); |
107 | } |
108 | |
109 | public function varchar(int $maximum = null) : VarcharColumn |
110 | { |
111 | return $this->column = new VarcharColumn($this->database, $maximum); |
112 | } |
113 | |
114 | public function char(int $maximum = null) : CharColumn |
115 | { |
116 | return $this->column = new CharColumn($this->database, $maximum); |
117 | } |
118 | |
119 | public function enum(string $value, string ...$values) : EnumColumn |
120 | { |
121 | return $this->column = new EnumColumn($this->database, $value, ...$values); |
122 | } |
123 | |
124 | public function set(string $value, string ...$values) : SetColumn |
125 | { |
126 | return $this->column = new SetColumn($this->database, $value, ...$values); |
127 | } |
128 | |
129 | public function text(int $maximum = null) : TextColumn |
130 | { |
131 | return $this->column = new TextColumn($this->database, $maximum); |
132 | } |
133 | |
134 | public function longtext() : LongtextColumn |
135 | { |
136 | return $this->column = new LongtextColumn($this->database); |
137 | } |
138 | |
139 | public function mediumtext() : MediumtextColumn |
140 | { |
141 | return $this->column = new MediumtextColumn($this->database); |
142 | } |
143 | |
144 | public function tinytext() : TinytextColumn |
145 | { |
146 | return $this->column = new TinytextColumn($this->database); |
147 | } |
148 | |
149 | public function json() : JsonColumn |
150 | { |
151 | return $this->column = new JsonColumn($this->database); |
152 | } |
153 | |
154 | public function blob() : BlobColumn |
155 | { |
156 | return $this->column = new BlobColumn($this->database); |
157 | } |
158 | |
159 | public function tinyblob() : TinyblobColumn |
160 | { |
161 | return $this->column = new TinyblobColumn($this->database); |
162 | } |
163 | |
164 | public function mediumblob() : MediumblobColumn |
165 | { |
166 | return $this->column = new MediumblobColumn($this->database); |
167 | } |
168 | |
169 | public function longblob() : LongblobColumn |
170 | { |
171 | return $this->column = new LongblobColumn($this->database); |
172 | } |
173 | |
174 | public function bit() : BitColumn |
175 | { |
176 | return $this->column = new BitColumn($this->database); |
177 | } |
178 | |
179 | public function binary() : BinaryColumn |
180 | { |
181 | return $this->column = new BinaryColumn($this->database); |
182 | } |
183 | |
184 | public function varbinary() : VarbinaryColumn |
185 | { |
186 | return $this->column = new VarbinaryColumn($this->database); |
187 | } |
188 | |
189 | public function date() : DateColumn |
190 | { |
191 | return $this->column = new DateColumn($this->database); |
192 | } |
193 | |
194 | public function time() : TimeColumn |
195 | { |
196 | return $this->column = new TimeColumn($this->database); |
197 | } |
198 | |
199 | public function datetime() : DatetimeColumn |
200 | { |
201 | return $this->column = new DatetimeColumn($this->database); |
202 | } |
203 | |
204 | public function timestamp() : TimestampColumn |
205 | { |
206 | return $this->column = new TimestampColumn($this->database); |
207 | } |
208 | |
209 | public function year() : YearColumn |
210 | { |
211 | return $this->column = new YearColumn($this->database); |
212 | } |
213 | |
214 | public function geometrycollection() : GeometryCollectionColumn |
215 | { |
216 | return $this->column = new GeometryCollectionColumn($this->database); |
217 | } |
218 | |
219 | public function geometry() : GeometryColumn |
220 | { |
221 | return $this->column = new GeometryColumn($this->database); |
222 | } |
223 | |
224 | public function linestring() : LinestringColumn |
225 | { |
226 | return $this->column = new LinestringColumn($this->database); |
227 | } |
228 | |
229 | public function multilinestring() : MultilinestringColumn |
230 | { |
231 | return $this->column = new MultilinestringColumn($this->database); |
232 | } |
233 | |
234 | public function multipoint() : MultipointColumn |
235 | { |
236 | return $this->column = new MultipointColumn($this->database); |
237 | } |
238 | |
239 | public function multipolygon() : MultipolygonColumn |
240 | { |
241 | return $this->column = new MultipolygonColumn($this->database); |
242 | } |
243 | |
244 | public function point() : PointColumn |
245 | { |
246 | return $this->column = new PointColumn($this->database); |
247 | } |
248 | |
249 | public function polygon() : PolygonColumn |
250 | { |
251 | return $this->column = new PolygonColumn($this->database); |
252 | } |
253 | |
254 | protected function sql() : string |
255 | { |
256 | return $this->column->sql(); |
257 | } |
258 | } |