Completed
Push — refactor-db-tests ( 8ba032 )
by Carsten
09:18
created

ColumnSchemaBuilder   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 2 Features 2
Metric Value
wmc 11
lcom 3
cbo 2
dl 0
loc 54
ccs 0
cts 32
cp 0
rs 10
c 2
b 2
f 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A buildUnsignedString() 0 4 2
A buildAfterString() 0 6 2
A buildFirstString() 0 4 2
A buildCommentString() 0 4 2
A __toString() 0 14 3
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\db\cubrid;
9
10
use yii\db\ColumnSchemaBuilder as AbstractColumnSchemaBuilder;
11
12
/**
13
 * ColumnSchemaBuilder is the schema builder for Cubrid 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
    protected function buildAfterString()
32
    {
33
        return $this->after !== null ?
34
            ' AFTER ' . $this->db->quoteColumnName($this->after) :
35
            '';
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    protected function buildFirstString()
42
    {
43
        return $this->isFirst ? ' FIRST' : '';
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    protected function buildCommentString()
50
    {
51
        return $this->comment !== null ? " COMMENT " . $this->db->quoteValue($this->comment) : '';
52
    }
53
54
    /**
55
     * @inheritdoc
56
     */
57
    public function __toString()
58
    {
59
        switch ($this->getTypeCategory()) {
60
            case self::CATEGORY_PK:
61
                $format = '{type}{check}{pos}{comment}{append}';
62
                break;
63
            case self::CATEGORY_NUMERIC:
64
                $format = '{type}{length}{unsigned}{notnull}{unique}{default}{check}{comment}{pos}{append}';
65
                break;
66
            default:
67
                $format = '{type}{length}{notnull}{unique}{default}{check}{comment}{pos}{append}';
68
        }
69
        return $this->buildCompleteString($format);
70
    }
71
}
72