Passed
Pull Request — master (#29)
by Sébastien
12:35 queued 04:51
created

TypesHelperTableBuilder::string()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Bdf\Prime\Schema\Builder;
4
5
use Bdf\Prime\Platform\PlatformTypeInterface;
6
use Bdf\Prime\Platform\PlatformTypesInterface;
7
use Bdf\Prime\Schema\IndexInterface;
8
use Bdf\Prime\Types\TypeInterface;
9
use Bdf\Prime\Types\TypesHelperInterface;
10
11
/**
12
 * Decorate TableBuilder for adding extra helper methods for adding types
13
 * Not like table builder, all helpers method will return $this
14
 * All those methods can be chained.
15
 *
16
 * The given type registry must be a @see PlatformTypesInterface for resolve "complex" types like bigint, or array
0 ignored issues
show
introduced by
Doc comment long description must end with a full stop
Loading history...
17
 *
18
 * <code>
19
 * $builder
20
 *     ->bigint('id')->autoincrement()->primary()
21
 *     ->string('first_name', 32)->nillable()->unique('idx_name')
22
 *     ->string('last_name', 32)->nillable()->unique('idx_name')
23
 * ;
24
 * </code>
25
 */
26
final class TypesHelperTableBuilder implements TableBuilderInterface, TypesHelperInterface
27
{
28
    /**
29
     * @var TableBuilderInterface
30
     */
31
    private $builder;
32
33
    /**
34
     * @var PlatformTypesInterface
35
     */
36
    private $types;
37
38
39
    /**
40
     * TypesHelperTableBuilder constructor.
41
     *
42
     * @param TableBuilderInterface $builder
43
     * @param PlatformTypesInterface $types
44
     */
45 249
    public function __construct(TableBuilderInterface $builder, PlatformTypesInterface $types)
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before function; 2 found
Loading history...
46
    {
47 249
        $this->builder = $builder;
48 249
        $this->types = $types;
49 249
    }
50
51
    //===================//
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// ===================//" but found "//===================//"
Loading history...
52
    // Delegated methods //
53
    //===================//
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// ===================//" but found "//===================//"
Loading history...
54
55
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
56
     * {@inheritdoc}
57
     */
58 1
    public function name($name)
59
    {
60 1
        $this->builder->name($name);
61
62 1
        return $this;
63
    }
64
65
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $options should have a doc-comment as per coding-style.
Loading history...
66
     * {@inheritdoc}
67
     */
68 1
    public function options(array $options)
69
    {
70 1
        $this->builder->options($options);
71
72 1
        return $this;
73
    }
74
75
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $indexes should have a doc-comment as per coding-style.
Loading history...
76
     * {@inheritdoc}
77
     */
78 1
    public function indexes(array $indexes)
79
    {
80 1
        $this->builder->indexes($indexes);
81
82 1
        return $this;
83
    }
84
85
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $columns should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
86
     * {@inheritdoc}
87
     */
88 157
    public function primary($columns = null, $name = null)
89
    {
90 157
        $this->builder->primary($columns, $name);
91
92 157
        return $this;
93
    }
94
95
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $column should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $type should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $options should have a doc-comment as per coding-style.
Loading history...
96
     * {@inheritdoc}
97
     */
98 241
    public function add($column, PlatformTypeInterface $type, array $options = [])
99
    {
100 241
        return $this->builder->add($column, $type, $options);
101
    }
102
103
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
104
     * {@inheritdoc}
105
     */
106 198
    public function column($name = null)
107
    {
108 198
        return $this->builder->column($name);
109
    }
110
111
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $foreignTable should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $localColumnNames should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $foreignColumnNames should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $options should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $constraintName should have a doc-comment as per coding-style.
Loading history...
112
     * {@inheritdoc}
113
     */
114 1
    public function foreignKey($foreignTable, array $localColumnNames, array $foreignColumnNames, array $options = [], $constraintName = null)
115
    {
116 1
        $this->builder->foreignKey($foreignTable, $localColumnNames, $foreignColumnNames, $options, $constraintName);
117
118 1
        return $this;
119
    }
120
121
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $columns should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $type should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $options should have a doc-comment as per coding-style.
Loading history...
122
     * {@inheritdoc}
123
     */
124 1
    public function index($columns, $type = IndexInterface::TYPE_SIMPLE, $name = null, array $options = [])
125
    {
126 1
        $this->builder->index($columns, $type, $name, $options);
127
128 1
        return $this;
129
    }
130
131
    /**
132
     * {@inheritdoc}
133
     */
134 212
    public function build()
135
    {
136 212
        return $this->builder->build();
137
    }
138
139
    //================//
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// ================//" but found "//================//"
Loading history...
140
    // Helper methods //
141
    //================//
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// ================//" but found "//================//"
Loading history...
142
143
    /**
144
     * Add a new column with type as string
145
     *
146
     * @param string $column
147
     * @param string $type
148
     * @param array $options
149
     *
150
     * @return ColumnBuilderInterface
151
     *
152
     * @see TableBuilderInterface::add()
153
     */
154 240
    public function addTypeAsString($column, $type, array $options = [])
155
    {
156 240
        return $this->add(
157 240
            $column,
158 240
            $this->types->native($type),
159 240
            $options
160
        );
161
    }
162
163
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $length should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
164
     * {@inheritdoc}
165
     */
166 211
    public function string($name, $length = 255, $default = null)
167
    {
168 211
        $this->addTypeAsString($name, TypeInterface::STRING)
169 211
            ->length($length)
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
introduced by
Object operator not indented correctly; expected 10 spaces but found 12
Loading history...
170 211
            ->setDefault($default)
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
Coding Style introduced by
Space after closing parenthesis of function call prohibited
Loading history...
171
        ;
0 ignored issues
show
Coding Style introduced by
Space found before semicolon; expected ");" but found ")
;"
Loading history...
172
173 211
        return $this;
174
    }
175
176
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
177
     * {@inheritdoc}
178
     */
179 2
    public function text($name, $default = null)
180
    {
181 2
        $this->addTypeAsString($name, TypeInterface::TEXT)->setDefault($default);
182
183 2
        return $this;
184
    }
185
186
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
187
     * {@inheritdoc}
188
     */
189 24
    public function integer($name, $default = null)
190
    {
191 24
        $this->addTypeAsString($name, TypeInterface::INTEGER)->setDefault($default);
192
193 24
        return $this;
194
    }
195
196
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
197
     * {@inheritdoc}
198
     */
199 2
    public function tinyint($name, $default = null)
200
    {
201 2
        $this->addTypeAsString($name, TypeInterface::TINYINT)->setDefault($default);
202
203 2
        return $this;
204
    }
205
206
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
207
     * {@inheritdoc}
208
     */
209 2
    public function smallint($name, $default = null)
210
    {
211 2
        $this->addTypeAsString($name, TypeInterface::SMALLINT)->setDefault($default);
212
213 2
        return $this;
214
    }
215
216
    /**
217
     * Create a new medium integer (3-byte) column on the table.
218
     *
219
     * @param  string  $name
0 ignored issues
show
introduced by
Tag value indented incorrectly; expected 1 space but found 2
Loading history...
220
     * @param  mixed   $default
0 ignored issues
show
introduced by
Tag value indented incorrectly; expected 1 space but found 2
Loading history...
221
     *
222
     * @return $this
223
     */
224
    public function mediumint($name, $default = null)
225
    {
226
        $this->addTypeAsString($name, 'mediumint')->setDefault($default);
227
228
        return $this;
229
    }
230
231
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
232
     * {@inheritdoc}
233
     */
234 160
    public function bigint($name, $default = null)
235
    {
236 160
        $this->addTypeAsString($name, TypeInterface::BIGINT)->setDefault($default);
237
238 160
        return $this;
239
    }
240
241
    /**
242
     * Create a new unsigned tiny integer (1-byte) column on the table.
243
     *
244
     * @param string $name
245
     * @param mixed $default
246
     *
247
     * @return $this
248
     */
249 1
    public function unsignedTinyint($name, $default = null)
250
    {
251 1
        return $this->tinyint($name, $default)->unsigned();
252
    }
253
254
    /**
255
     * Create a new unsigned small integer (2-byte) column on the table.
256
     *
257
     * @param string $name
258
     * @param mixed $default
259
     *
260
     * @return $this
261
     */
262 1
    public function unsignedSmallint($name, $default = null)
263
    {
264 1
        return $this->smallint($name, $default)->unsigned();
265
    }
266
267
    /**
268
     * Create a new unsigned medium integer (3-byte) column on the table.
269
     *
270
     * @param string $name
271
     * @param mixed $default
272
     *
273
     * @return $this
274
     */
275
    public function unsignedMediumint($name, $default = null)
276
    {
277
        return $this->mediumint($name, $default)->unsigned();
278
    }
279
280
    /**
281
     * Create a new unsigned integer (4-byte) column on the table.
282
     *
283
     * @param string $name
284
     * @param mixed $default
285
     *
286
     * @return $this
287
     */
288 1
    public function unsignedInteger($name, $default = null)
289
    {
290 1
        return $this->integer($name, $default)->unsigned();
291
    }
292
293
    /**
294
     * Create a new unsigned big integer (8-byte) column on the table.
295
     *
296
     * @param string $name
297
     * @param mixed $default
298
     *
299
     * @return $this
300
     */
301 1
    public function unsignedBigint($name, $default = null)
302
    {
303 1
        return $this->bigint($name, $default)->unsigned();
304
    }
305
306
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
307
     * {@inheritdoc}
308
     */
309 1
    public function float($name, $default = null)
310
    {
311 1
        $this->addTypeAsString($name, TypeInterface::FLOAT)->setDefault($default);
312
313 1
        return $this;
314
    }
315
316
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
317
     * {@inheritdoc}
318
     */
319 1
    public function double($name, $default = null)
320
    {
321 1
        $this->addTypeAsString($name, TypeInterface::DOUBLE)->setDefault($default);
322
323 1
        return $this;
324
    }
325
326
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
327
     * {@inheritdoc}
328
     */
329
    public function decimal($name, $default = null)
330
    {
331
        $this->addTypeAsString($name, TypeInterface::DECIMAL)->setDefault($default);
332
333
        return $this;
334
    }
335
336
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
337
     * {@inheritdoc}
338
     */
339 3
    public function boolean($name, $default = null)
340
    {
341 3
        $this->addTypeAsString($name, TypeInterface::BOOLEAN)->setDefault($default);
342
343 3
        return $this;
344
    }
345
346
    /**
347
     * Create a new enum column on the table.
348
     *
349
     * @param  string  $name
0 ignored issues
show
introduced by
Tag value indented incorrectly; expected 1 space but found 2
Loading history...
350
     * @param  array   $allowed
0 ignored issues
show
introduced by
Tag value indented incorrectly; expected 1 space but found 2
Loading history...
351
     *
352
     * @return $this
353
     */
354
//    public function enum($name, array $allowed)
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 4 spaces, found 0
Loading history...
Coding Style introduced by
Expected 1 space before comment text but found 4; use block comment if you need indentation
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
introduced by
4 spaces found before inline comment; expected "// public function enum($name, array $allowed)" but found "// public function enum($name, array $allowed)"
Loading history...
355
//    {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 4 spaces, found 0
Loading history...
Coding Style introduced by
Expected 1 space before comment text but found 4; use block comment if you need indentation
Loading history...
356
//        $this->addTypeAsString($name, 'enum', ['allowed' => $allowed]);
0 ignored issues
show
Coding Style introduced by
Expected 1 space before comment text but found 8; use block comment if you need indentation
Loading history...
Coding Style introduced by
Line indented incorrectly; expected at least 4 spaces, found 0
Loading history...
introduced by
Comment indentation error, expected only 4 spaces
Loading history...
357
//
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 4 spaces, found 0
Loading history...
358
//        return $this;
0 ignored issues
show
Coding Style introduced by
Expected 1 space before comment text but found 8; use block comment if you need indentation
Loading history...
Coding Style introduced by
Line indented incorrectly; expected at least 4 spaces, found 0
Loading history...
359
//    }
0 ignored issues
show
Coding Style introduced by
Expected 1 space before comment text but found 4; use block comment if you need indentation
Loading history...
Coding Style introduced by
Line indented incorrectly; expected at least 4 spaces, found 0
Loading history...
360
361
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
362
     * {@inheritdoc}
363
     */
364
    public function date($name, $default = null)
365
    {
366
        $this->addTypeAsString($name, TypeInterface::DATE)->setDefault($default);
367
368
        return $this;
369
    }
370
371
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
372
     * {@inheritdoc}
373
     */
374 111
    public function dateTime($name, $default = null)
375
    {
376 111
        $this->addTypeAsString($name, TypeInterface::DATETIME)->setDefault($default);
377
378 111
        return $this;
379
    }
380
381
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
382
     * {@inheritdoc}
383
     */
384
    public function dateTimeTz($name, $default = null)
385
    {
386
        $this->addTypeAsString($name, TypeInterface::DATETIMETZ)->setDefault($default);
387
388
        return $this;
389
    }
390
391
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
392
     * {@inheritdoc}
393
     */
394
    public function time($name, $default = null)
395
    {
396
        $this->addTypeAsString($name, TypeInterface::TIME)->setDefault($default);
397
398
        return $this;
399
    }
400
401
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
402
     * {@inheritdoc}
403
     */
404
    public function timestamp($name, $default = null)
405
    {
406
        $this->addTypeAsString($name, TypeInterface::TIMESTAMP)->setDefault($default);
407
408
        return $this;
409
    }
410
411
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
412
     * {@inheritdoc}
413
     */
414 1
    public function binary($name, $default = null)
415
    {
416 1
        $this->addTypeAsString($name, TypeInterface::BINARY)->setDefault($default);
417
418 1
        return $this;
419
    }
420
421
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
422
     * {@inheritdoc}
423
     */
424 1
    public function blob($name, $default = null)
425
    {
426 1
        $this->addTypeAsString($name, TypeInterface::BLOB)->setDefault($default);
427
428 1
        return $this;
429
    }
430
431
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
432
     * {@inheritdoc}
433
     */
434
    public function guid($name, $default = null)
435
    {
436
        $this->addTypeAsString($name, TypeInterface::GUID)->setDefault($default);
437
438
        return $this;
439
    }
440
441
    /**
442
     * Create a new json column on the table.
443
     *
444
     * @param  string  $name
0 ignored issues
show
introduced by
Tag value indented incorrectly; expected 1 space but found 2
Loading history...
445
     * @param  mixed   $default
0 ignored issues
show
introduced by
Tag value indented incorrectly; expected 1 space but found 2
Loading history...
446
     *
447
     * @return $this
448
     */
449 1
    public function json($name, $default = null)
450
    {
451 1
        $this->addTypeAsString($name, TypeInterface::JSON)->setDefault($default);
452
453 1
        return $this;
454
    }
455
456
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
457
     * {@inheritdoc}
458
     */
459 1
    public function simpleArray($name, $default = null)
460
    {
461 1
        $this->addTypeAsString($name, TypeInterface::TARRAY)->setDefault($default);
462
463 1
        return $this;
464
    }
465
466
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
467
     * {@inheritdoc}
468
     */
469 1
    public function object($name, $default = null)
470
    {
471 1
        $this->addTypeAsString($name, TypeInterface::OBJECT)->setDefault($default);
472
473 1
        return $this;
474
    }
475
476
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
477
     * {@inheritdoc}
478
     */
479 1
    public function arrayObject($name, $default = null)
480
    {
481 1
        $this->addTypeAsString($name, TypeInterface::ARRAY_OBJECT)->setDefault($default);
482
483 1
        return $this;
484
    }
485
486
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
487
     * {@inheritdoc}
488
     */
489 1
    public function searchableArray($name, $default = null)
490
    {
491 1
        $this->addTypeAsString($name, TypeInterface::TARRAY)->setDefault($default);
492
493 1
        return $this;
494
    }
495
496
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $type should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
497
     * {@inheritdoc}
498
     */
499 4
    public function arrayOf($name, $type, $default = null)
500
    {
501 4
        $this->addTypeAsString($name, $type.'[]')->setDefault($default);
502
503 4
        return $this;
504
    }
505
506
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
507
     * {@inheritdoc}
508
     */
509 1
    public function arrayOfInt($name, $default = null)
510
    {
511 1
        return $this->arrayOf($name, TypeInterface::INTEGER, $default);
512
    }
513
514
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
515
     * {@inheritdoc}
516
     */
517 1
    public function arrayOfDouble($name, $default = null)
518
    {
519 1
        return $this->arrayOf($name, TypeInterface::DOUBLE, $default);
520
    }
521
522
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $name should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $default should have a doc-comment as per coding-style.
Loading history...
523
     * {@inheritdoc}
524
     */
525 1
    public function arrayOfDateTime($name, $default = null)
526
    {
527 1
        return $this->arrayOf($name, TypeInterface::DATETIME, $default);
528
    }
529
530
    /**
531
     * Specify the autoincrement key.
532
     * /!\ Unlike FieldBuilder, this method will not set the column as primary key
533
     *
534
     * @param bool $flag         Activate/Deactivate autoincrement
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for parameter type
Loading history...
535
     *
536
     * @return $this
537
     *
538
     * @see ColumnBuilderInterface::autoincrement()
539
     */
540 137
    public function autoincrement($flag = true)
541
    {
542 137
        $this->column()->autoincrement($flag);
543
544 137
        return $this;
545
    }
546
547
    /**
548
     * Set nillable flag of current field
549
     *
550
     * @param bool $flag         Activate/Deactivate nillable
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for parameter type
Loading history...
551
     *
552
     * @return $this             This builder instance
553
     */
554 136
    public function nillable($flag = true)
555
    {
556 136
        $this->column()->nillable($flag);
557
558 136
        return $this;
559
    }
560
561
    /**
562
     * Set unsigned flag on the current field
563
     *
564
     * @param bool $flag Activate/Deactivate unsigned
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for parameter type
Loading history...
565
     *
566
     * @return $this This builder instance
567
     */
568 8
    public function unsigned($flag = true)
569
    {
570 8
        $this->column()->unsigned($flag);
571
572 8
        return $this;
573
    }
574
575
    /**
576
     * Define the decimal field precision
577
     *
578
     * @param int $precision The number of significant digits that are stored for values
0 ignored issues
show
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
579
     * @param int $scale The number of digits that can be stored following the decimal point
0 ignored issues
show
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
580
     *
581
     * @return $this This builder instance
582
     */
583 2
    public function precision(int $precision, int $scale)
584
    {
585 2
        $this->column()->precision($precision, $scale);
586
587 2
        return $this;
588
    }
589
}
590