Passed
Push — fix-tests ( 6dd538...727178 )
by Alexander
195:41 queued 192:18
created

ColumnSchemaBuilder::buildAfterString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

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