Completed
Push — master ( de4017...bfb2d5 )
by Viacheslav
06:58 queued 03:15
created

TypeString::getIntTypeString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Yaoi\Database\Pgsql;
4
5
6
use Yaoi\Database\Definition\Column;
7
8
class TypeString extends \Yaoi\Database\Mysql\TypeString
9
{
10
    public function getByColumn(Column $column)
11
    {
12
        if ($column->flags & Column::AUTO_ID) {
13
            return 'SERIAL';
14
        }
15
16
        $flags = $column->flags;
17
18
        $typeString = $this->getBaseType($column);
19
20
        if ($flags & Column::UNSIGNED) {
21
            $typeString .= ' unsigned';
22
        }
23
24
        if ($flags & Column::NOT_NULL) {
25
            $typeString .= ' NOT NULL';
26
        }
27
28
        $default = $column->getDefault();
29
        if ((false !== $default) && null !== $default) {
30
            $typeString .= $this->database->expr(" DEFAULT ?", $default);
31
        }
32
33
        return $typeString;
34
    }
35
36
    protected function getIntTypeString(Column $column)
37
    {
38
        $intType = 'int';
39
        return $intType;
40
    }
41
42
    protected function getFloatTypeString(Column $column)
43
    {
44
        return 'float';
45
    }
46
47
}