Completed
Push — master ( dbcbc1...04d817 )
by Sébastien
02:01
created

PdoSqliteAdapter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 38
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 3 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
11
class PdoSqliteAdapter extends GenericPdo implements AdapterInterface
12
{
13
14
    /**
15
     *
16
     * @var \PDO
17
     */
18
    protected $resource;
19
20
21
    /**
22
     * Constructor
23
     *
24
     * @throws Exception\InvalidArgumentException
25
     * @throws Exception\RuntimeException
26
     * @param \PDO $resource
27
     */
28 5
    public function __construct(PDO $resource)
29
    {
30 5
        $this->checkEnvironment();
31 5
        if ($resource->getAttribute(\PDO::ATTR_DRIVER_NAME) != 'sqlite') {
32 1
            $msg = __CLASS__ . " requires pdo connection to be 'sqlite'";
33 1
            throw new Exception\InvalidArgumentException($msg);
34
        }
35 5
        $this->resource = $resource;
36 5
        $this->connection = new PdoSqliteConnection($this, $resource);
0 ignored issues
show
Bug introduced by
The property connection does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
37 5
    }
38
    
39
    
40
    /**
41
     * {@inheritdoc}
42
     * @return PdoSqliteConnection
43
     */
44 2
    public function getConnection() {
45 2
        return $this->connection;    
46
    }    
47
    
48
}
49