Completed
Push — master ( 7fd5f6...af8ac7 )
by James Ekow Abaka
01:40
created

PostgresqlAdapter::mapDataTypes()   C

Complexity

Conditions 9
Paths 9

Size

Total Lines 22
Code Lines 18

Duplication

Lines 22
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 90

Importance

Changes 0
Metric Value
dl 22
loc 22
ccs 0
cts 16
cp 0
rs 6.412
c 0
b 0
f 0
cc 9
eloc 18
nc 9
nop 1
crap 90
1
<?php
2
namespace ntentan\nibii\adapters;
3
4 View Code Duplication
class PostgresqlAdapter extends \ntentan\nibii\DriverAdapter
5
{
6
    /**
7
     * Convert from postgresqls native type to a generic type accepted in the
8
     * atiaa library.
9
     * @param string $nativeType
10
     * @return string
11
     * @throws \Exception
12
     */
13
    public function mapDataTypes($nativeType) 
14
    {
15
        switch($nativeType)
16
        {
17
            case 'character varying':
18
                return 'string';
19
            case 'text':
20
                return 'text';
21
            case 'date':
22
                return 'date';
23
            case 'integer':
24
            case 'boolean':
25
                return $nativeType;
26
            case 'numeric':
27
                return 'double';
28
            case 'timestamp without time zone':
29
            case 'timestamp with time zone':
30
                return 'datetime';
31
            default:
32
                throw new \Exception("Unknown type {$nativeType}");
33
        }
34
    }
35
}
36