Completed
Push — master ( 61665e...00db75 )
by James Ekow Abaka
03:32
created

PostgresqlAdapter   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 32
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 1
dl 32
loc 32
ccs 12
cts 16
cp 0.75
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C mapDataTypes() 22 22 9

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace ntentan\nibii\adapters;
3
4 View Code Duplication
class PostgresqlAdapter extends \ntentan\nibii\DriverAdapter
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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 14
    public function mapDataTypes($nativeType) 
14
    {
15
        switch($nativeType)
16
        {
17 14
            case 'character varying':
18 14
                return 'string';
19 14
            case 'text':
20 2
                return 'text';
21 14
            case 'date':
22
                return 'date';
23 14
            case 'integer':
24 10
            case 'boolean':
25 14
                return $nativeType;
26 10
            case 'numeric':
27
                return 'double';
28 10
            case 'timestamp without time zone':
29
            case 'timestamp with time zone':
30 10
                return 'datetime';
31
            default:
32
                throw new \Exception("Unknown type {$nativeType}");
33
        }
34
    }
35
}
36