Completed
Push — fix-unique-exists-expressions ( b0719b...8467f4 )
by Alexander
07:52
created

ColumnSchemaBuilder::buildFirstString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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