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

PostgresqlAdapter   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 84.62%

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 7
c 4
b 0
f 1
lcom 0
cbo 1
dl 0
loc 29
ccs 11
cts 13
cp 0.8462
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B mapDataTypes() 0 19 7
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