Passed
Push — master ( 1f0d9b...6a4b0f )
by Wilmer
12:11 queued 10:38
created

ColumnSchemaBuilder   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 51
ccs 14
cts 18
cp 0.7778
rs 10
c 0
b 0
f 0
wmc 11

5 Methods

Rating   Name   Duplication   Size   Complexity  
A buildUnsignedString() 0 3 2
A buildFirstString() 0 3 2
A __toString() 0 14 3
A buildCommentString() 0 3 2
A buildAfterString() 0 3 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Mysql\Schema;
6
7
use Yiisoft\Db\Schema\ColumnSchemaBuilder as AbstractColumnSchemaBuilder;
8
9
/**
10
 * ColumnSchemaBuilder is the schema builder for MySQL databases.
11
 */
12
class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 4
    protected function buildUnsignedString(): string
18
    {
19 4
        return $this->getIsUnsigned() ? ' UNSIGNED' : '';
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 4
    protected function buildAfterString(): string
26
    {
27 4
        return $this->getAfter() !== null ? ' AFTER ' . $this->getDb()->quoteColumnName($this->getAfter()) : '';
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    protected function buildFirstString(): string
34
    {
35
        return $this->getIsFirst() ? ' FIRST' : '';
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 4
    protected function buildCommentString(): string
42
    {
43 4
        return $this->getComment() !== null ? ' COMMENT ' . $this->getDb()->quoteValue($this->getComment()) : '';
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 4
    public function __toString(): string
50
    {
51 4
        switch ($this->getTypeCategory()) {
52 4
            case self::CATEGORY_PK:
53
                $format = '{type}{length}{comment}{check}{append}{pos}';
54
                break;
55 4
            case self::CATEGORY_NUMERIC:
56 3
                $format = '{type}{length}{unsigned}{notnull}{default}{unique}{comment}{append}{pos}{check}';
57 3
                break;
58
            default:
59 1
                $format = '{type}{length}{notnull}{default}{unique}{comment}{append}{pos}{check}';
60
        }
61
62 4
        return $this->buildCompleteString($format);
63
    }
64
}
65