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

Connection::setConnector()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
namespace Dazzle\PgSQL\Connection;
3
4
use Dazzle\Promise\Deferred;
5
use Dazzle\Promise\PromiseInterface;
6
use Dazzle\PgSQL\Transaction\Transaction;
7
use Dazzle\PgSQL\Connection\ConnectorInterface;
8
9
class Connection extends Deferred implements ConnectionInterface
10
{
11
    /**
12
     * @var ConnectorInterface
13
     */
14
    protected $connector;
15
16
    public function getConnector()
17
    {
18
        return $this->connector;
19
    }
20
21
    public function setConnector(ConnectorInterface $connector)
22
    {
23
        $this->connector = $connector;
24
    }
25
26
    public function query($sql, $params = [])
27
    {
28
        return $this->connector->query($sql, $params);
29
    }
30
31
    public function execute($sql, $params = [])
32
    {
33
        return $this->connector->execute($sql, $params = []);
34
    }
35
36
    /**
37
     * @param $sql
38
     * @return PromiseInterface
39
     */
40
    public function prepare($sql)
41
    {
42
        return $this->connector->prepare($sql);
43
    }
44
45
    public function beginTransaction()
46
    {
47
        $transac = new Transaction($this->connector);
0 ignored issues
show
Bug introduced by
The call to Transaction::__construct() misses a required argument $emitter.

This check looks for function calls that miss required arguments.

Loading history...
48
        
49
        return $transac->begin();
50
    }
51
}