Completed
Push — prepare-travis-for-js ( a7ee60...8c0a43 )
by Carsten
17:00 queued 09:50
created

ColumnSchemaBuilder::buildCommentString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 2
eloc 2
nc 2
nop 0
crap 2
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\mysql;
9
10
use yii\db\ColumnSchemaBuilder as AbstractColumnSchemaBuilder;
11
12
/**
13
 * ColumnSchemaBuilder is the schema builder for MySQL 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 4
    protected function buildUnsignedString()
24
    {
25 4
        return $this->isUnsigned ? ' UNSIGNED' : '';
26
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31 4
    protected function buildAfterString()
32
    {
33 4
        return $this->after !== null ?
34 4
            ' AFTER ' . $this->db->quoteColumnName($this->after) :
35 4
            '';
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41 1
    protected function buildFirstString()
42
    {
43 1
        return $this->isFirst ? ' FIRST' : '';
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49 4
    protected function buildCommentString()
50
    {
51 4
        return $this->comment !== null ? ' COMMENT ' . $this->db->quoteValue($this->comment) : '';
52
    }
53
54
    /**
55
     * @inheritdoc
56
     */
57 4
    public function __toString()
58
    {
59 4
        switch ($this->getTypeCategory()) {
60 4
            case self::CATEGORY_PK:
61 1
                $format = '{type}{length}{check}{comment}{pos}{append}';
62 1
                break;
63 4
            case self::CATEGORY_NUMERIC:
64 4
                $format = '{type}{length}{unsigned}{notnull}{unique}{default}{check}{comment}{pos}{append}';
65 4
                break;
66 1
            default:
67 1
                $format = '{type}{length}{notnull}{unique}{default}{check}{comment}{pos}{append}';
68 4
        }
69 4
        return $this->buildCompleteString($format);
70
    }
71
}
72