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

StatementHandlerTrait::handle()   B

Complexity

Conditions 7
Paths 7

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 56

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 0
cts 16
cp 0
rs 8.2222
c 0
b 0
f 0
cc 7
eloc 13
nc 7
nop 1
crap 56
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
}