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

ColumnSchemaBuilder   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 12
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 14 3
A buildUnsignedString() 0 3 2
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