PdoSqliteAdapter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 41
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A getConnection() 0 4 1
1
<?php
2
3
namespace Soluble\DbWrapper\Adapter;
4
5
use Soluble\DbWrapper\Exception;
6
use Soluble\DbWrapper\Adapter\Pdo\GenericPdo;
7
use Soluble\DbWrapper\Connection\PdoSqliteConnection;
8
use PDO;
9
10
class PdoSqliteAdapter extends GenericPdo implements AdapterInterface
11
{
12
    /**
13
     * @var \PDO
14
     */
15
    protected $resource;
16
17
    /**
18
     * @var PdoSqliteConnection
19
     */
20
    protected $connection;
21
22
    /**
23
     * Constructor.
24
     *
25
     * @throws Exception\InvalidArgumentException
26
     * @throws Exception\RuntimeException
27
     *
28
     * @param \PDO $resource
29
     */
30 7
    public function __construct(PDO $resource)
31
    {
32 7
        $this->checkEnvironment();
33 7
        if ($resource->getAttribute(\PDO::ATTR_DRIVER_NAME) != 'sqlite') {
34 1
            $msg = __CLASS__ . " requires pdo connection to be 'sqlite'";
35 1
            throw new Exception\InvalidArgumentException($msg);
36
        }
37 7
        $this->resource = $resource;
38 7
        $this->connection = new PdoSqliteConnection($this, $resource);
39 7
    }
40
41
    /**
42
     * {@inheritdoc}
43
     *
44
     * @return PdoSqliteConnection
45
     */
46 3
    public function getConnection()
47
    {
48 3
        return $this->connection;
49
    }
50
}
51