Completed
Push — master ( 20d81d...6bd930 )
by Rasmus
02:25
created

PostgresDriver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 25%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 21
ccs 2
cts 8
cp 0.25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A quoteName() 0 4 1
A getExceptionType() 0 13 3
1
<?php
2
3
namespace mindplay\sql\postgres;
4
5
use mindplay\sql\exceptions\ForeignKeyException;
6
use mindplay\sql\exceptions\SQLException;
7
use mindplay\sql\exceptions\UniqueConstraintException;
8
use mindplay\sql\framework\Driver;
9
10
class PostgresDriver implements Driver
11
{
12 1
    public function quoteName($name)
13
    {
14 1
        return '"' . $name . '"';
15
    }
16
17
    public function getExceptionType($sql_state, $error_code, $error_message)
18
    {
19
        switch ($sql_state) {
20
            case '23503':
21
                return ForeignKeyException::class;
22
23
            case '23505':
24
                return UniqueConstraintException::class;
25
26
            default:
27
                return SQLException::class;
28
        }
29
    }
30
}
31