Passed
Pull Request — master (#20362)
by Wilmer
05:37
created

ColumnSchemaBuilder::buildUnsignedString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @link https://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license https://www.yiiframework.com/license/
6
 */
7
8
namespace yii\db\sqlite;
9
10
use yii\db\ColumnSchemaBuilder as AbstractColumnSchemaBuilder;
11
12
/**
13
 * ColumnSchemaBuilder is the schema builder for Sqlite databases.
14
 *
15
 * @author Chris Harris <[email protected]>
16
 * @since 2.0.8
17
 */
18
class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    protected function buildUnsignedString()
24
    {
25
        return $this->isUnsigned ? ' UNSIGNED' : '';
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function __toString()
32
    {
33
        switch ($this->getTypeCategory()) {
34
            case self::CATEGORY_PK:
35
                $format = '{type}{check}{append}';
36
                break;
37
            case self::CATEGORY_NUMERIC:
38
                $format = '{type}{length}{unsigned}{notnull}{unique}{check}{default}{append}';
39
                break;
40
            default:
41
                $format = '{type}{length}{notnull}{unique}{check}{default}{append}';
42
        }
43
44
        return $this->buildCompleteString($format);
45
    }
46
}
47