Passed
Push — master ( 21771a...749afb )
by Wilmer
18:31 queued 03:34
created

ColumnSchemaBuilder::__toString()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 3
nop 0
dl 0
loc 14
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Sqlite;
6
7
use Yiisoft\Db\Schema\ColumnSchemaBuilder as AbstractColumnSchemaBuilder;
8
9
final class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder
10
{
11
    /**
12
     * Builds the unsigned string for column. Defaults to unsupported.
13
     *
14
     * @return string a string containing UNSIGNED keyword.
15
     */
16
    protected function buildUnsignedString(): string
17
    {
18
        return $this->isUnsigned() ? ' UNSIGNED' : '';
19
    }
20
21
    public function __toString(): string
22
    {
23
        switch ($this->getTypeCategory()) {
24
            case self::CATEGORY_PK:
25
                $format = '{type}{check}{append}';
26
                break;
27
            case self::CATEGORY_NUMERIC:
28
                $format = '{type}{length}{unsigned}{notnull}{unique}{check}{default}{append}';
29
                break;
30
            default:
31
                $format = '{type}{length}{notnull}{unique}{check}{default}{append}';
32
        }
33
34
        return $this->buildCompleteString($format);
35
    }
36
}
37