Completed
Push — master ( 145f77...f73370 )
by James Ekow Abaka
04:01
created

PostgresqlAdapter::mapDataTypes()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 19
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 7.1782

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 19
ccs 11
cts 13
cp 0.8462
rs 8.2222
cc 7
eloc 15
nc 7
nop 1
crap 7.1782
1
<?php
2
namespace ntentan\nibii\adapters;
3
4
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 4
    public function mapDataTypes($nativeType) 
14
    {
15
        switch($nativeType)
16
        {
17 4
            case 'character varying':
18 4
                return 'string';
19 4
            case 'text':
20 2
                return 'text';
21 4
            case 'date':
22
                return 'date';
23 4
            case 'integer':
24 2
            case 'boolean':
25 4
                return $nativeType;
26 2
            case 'timestamp without time zone':
27 2
                return 'datetime';
28
            default:
29
                throw new \Exception("Unknown type {$nativeType}");
30
        }
31
    }
32
}
33