Passed
Pull Request — master (#7)
by Wilmer
12:36
created

ColumnSchemaBuilder   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildUnsignedString() 0 3 2
A __toString() 0 14 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Sqlite\Schema;
6
7
use Yiisoft\Db\Schemas\ColumnSchemaBuilder as AbstractColumnSchemaBuilder;
8
9
/**
10
 * ColumnSchemaBuilder is the schema builder for Sqlite databases.
11
 */
12
class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    protected function buildUnsignedString(): string
18
    {
19
        return $this->isUnsigned ? ' UNSIGNED' : '';
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function __toString(): string
26
    {
27
        switch ($this->getTypeCategory()) {
28
            case self::CATEGORY_PK:
29
                $format = '{type}{check}{append}';
30
                break;
31
            case self::CATEGORY_NUMERIC:
32
                $format = '{type}{length}{unsigned}{notnull}{unique}{check}{default}{append}';
33
                break;
34
            default:
35
                $format = '{type}{length}{notnull}{unique}{check}{default}{append}';
36
        }
37
38
        return $this->buildCompleteString($format);
39
    }
40
}
41