Completed
Pull Request — master (#1)
by
unknown
08:32
created

StatementHandlerTrait   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 0
loc 19
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 0 16 7
1
<?php
2
namespace Dazzle\PgSQL\Statement;
3
4
use Dazzle\PgSQL\Result\Tuple;
5
use Dazzle\PgSQL\Result\CommandResult;
6
7
trait StatementHandlerTrait
8
{
9
    public function handle($result)
10
    {
11
        $stat = pg_result_status($result, \PGSQL_STATUS_LONG);
12
        switch ($stat) {
13
            case PGSQL_EMPTY_QUERY:
14
                break;
15
            case PGSQL_COMMAND_OK:
16
                return new CommandResult($result);
17
            case PGSQL_TUPLES_OK:
18
                return new Tuple($result);
19
            case PGSQL_BAD_RESPONSE:
20
            case PGSQL_NONFATAL_ERROR:
21
            case PGSQL_FATAL_ERROR:
22
                return new \Exception('error');
23
        }
24
    }
25
}