Completed
Push — master ( fb8d74...ff1e54 )
by Sébastien
02:09
created

MysqliConnection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 46
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getResource() 0 4 1
A getHost() 0 5 1
1
<?php
2
3
namespace Soluble\DbWrapper\Connection;
4
5
use Soluble\DbWrapper\Adapter\MysqliAdapter;
6
use Soluble\DbWrapper\Connection\Mysql\AbstractMysqlConnection;
7
use mysqli;
8
9
class MysqliConnection extends AbstractMysqlConnection implements ConnectionInterface
10
{
11
12
    /**
13
     *
14
     * @var MysqliAdapter
15
     */
16
    protected $adapter;
17
18
19
    /**
20
     *
21
     * @var mysqli
22
     */
23
    protected $resource;
24
25
    /**
26
     *
27
     * @param MysqliAdapter $adapter
28
     * @param mysqli $resource
29
     */
30 8
    public function __construct(MysqliAdapter $adapter, $resource)
31
    {
32 8
        $this->adapter = $adapter;
33 8
        $this->resource = $resource;
34 8
    }
35
36
37
    /**
38
     * {@inheritdoc}
39
     * @return \mysqli
40
     */
41 1
    public function getResource()
42
    {
43 1
        return $this->resource;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 1
    public function getHost()
50
    {
51 1
        $infos = explode(' ', trim($this->resource->host_info));
52 1
        return strtolower($infos[0]);
53
    }
54
}
55