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

Prepared   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 5
dl 0
loc 39
ccs 0
cts 25
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getParams() 0 4 1
A setParams() 0 6 1
A execute() 0 4 1
A execPreparedStmt() 0 8 1
1
<?php
2
namespace Dazzle\PgSQL\Statement;
3
4
use Dazzle\PgSQL\Connection\ConnectorInterface;
5
use Dazzle\Promise\Deferred;
6
7
class Prepared extends Deferred implements PreparedStatement
8
{
9
    use StatementAwareTrait;
10
    use StatementHandlerTrait;
11
12
    protected $prepare;
13
14
    public function __construct(PrepareQuery $prepare)
15
    {
16
        parent::__construct();
17
        $this->prepare = $prepare;
18
    }
19
20
    public function getParams()
21
    {
22
        return $this->prepare->getParams();
23
    }
24
25
    public function setParams(array $params = [])
26
    {
27
        $this->prepare->setParams($params);
28
29
        return $this;
30
    }
31
32
    public function execute(ConnectorInterface $connector)
33
    {
34
        return \pg_send_execute($connector->getStream(), $this->prepare->getName(), $this->getParams());
35
    }
36
37
    public function execPreparedStmt()
38
    {
39
        $connector = $this->prepare->getPipe();
40
        $promise = $this->getPromise();
41
        $connector->appendQuery($this);
42
43
        return $promise;
44
    }
45
}