Completed
Push — master ( 58c9ab...b3ba9b )
by Sébastien
19:11 queued 01:31
created

ZendDb2Connection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 1
cbo 4
dl 0
loc 59
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getResource() 0 4 1
A getHost() 0 4 1
A getCurrentSchema() 0 9 2
1
<?php
2
3
namespace Soluble\DbWrapper\Connection\Zend;
4
5
use Soluble\DbWrapper\Adapter\AdapterInterface;
6
use Soluble\DbWrapper\Exception;
7
use Soluble\DbWrapper\Connection\ConnectionInterface;
8
9
class ZendDb2Connection implements ConnectionInterface
10
{
11
12
    /**
13
     *
14
     * @var AdapterInterface;
15
     */
16
    protected $adapter;
17
18
    /**
19
     *
20
     * @var \Zend\Db\Adapter\Adapter;
21
     */
22
    protected $zendAdapter;
23
24
    /**
25
     * @param AdapterInterface $adapter
26
     * @param \Zend\Db\Adapter\Adapter $zendAdapter
27
     */
28
    public function __construct(AdapterInterface $adapter, \Zend\Db\Adapter\Adapter $zendAdapter)
29
    {
30
        $this->adapter = $adapter;
31
        $this->zendAdapter = $zendAdapter;
32
    }
33
34
35
    /**
36
     * {@inheritdoc}
37
     * @return mixed
38
     */
39
    public function getResource()
40
    {
41
        return $this->zendAdapter->getDriver()->getConnection()->getResource();
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     * @throws Exception\UnsupportedFeatureException
47
     */
48
    public function getHost()
49
    {
50
        throw new Exception\UnsupportedFeatureException(__METHOD__ . " is not (yet) supported for zend-db bridge");
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     * @throws Exception\RuntimeException
56
     * @return string
57
     */
58
    public function getCurrentSchema()
59
    {
60
        try {
61
            $schema = $this->zendAdapter->getDriver()->getConnection()->getCurrentSchema();
62
        } catch (\Exception $e) {
63
            throw new Exception\RuntimeException("Cannot retrieve current schema:" . $e->getMessage());
64
        }
65
        return $schema;
66
    }
67
}
68