Completed
Push — master ( eccdf7...f1de52 )
by Mario
02:37
created

PDOStorage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2
1
<?php
2
/**
3
 * SQL Storage
4
 *
5
 * PHP Version 5.3
6
 *
7
 * @category  Payment
8
 * @package   KlarnaAPI
9
 * @author    MS Dev <[email protected]>
10
 * @copyright 2012 Klarna AB (http://klarna.com)
11
 * @license   http://opensource.org/licenses/BSD-2-Clause BSD-2
12
 * @link      https://developers.klarna.com/
13
 */
14
15
/**
16
 * Include the {@link PCStorage} interface.
17
 */
18
require_once 'sqlstorage.class.php';
19
20
/**
21
 * PDO storage class for KlarnaPClass
22
 *
23
 * @category  Payment
24
 * @package   KlarnaAPI
25
 * @author    MS Dev <[email protected]>
26
 * @copyright 2012 Klarna AB (http://klarna.com)
27
 * @license   http://opensource.org/licenses/BSD-2-Clause BSD-2
28
 * @link      https://developers.klarna.com/
29
 */
30
class PDOStorage extends SQLStorage
31
{
32
    /**
33
     * return the name of the storage type
34
     *
35
     * @return string
36
     */
37
    public function getName()
38
    {
39
        return "pdo";
40
    }
41
42
    /**
43
     * Connects to the DB.
44
     *
45
     * @param array|string $config
46
     * @throws Klarna_DatabaseException
47
     *
48
     * @return void
49
     */
50
    public function connect($config)
51
    {
52
        if(is_array($config) && $config['pdo'] instanceof PDO) {
53
            $this->pdo = $config['pdo'];
54
            $this->dbTable = $config['table'];
55
        } else {
56
            throw new Klarna_DatabaseException('URI is invalid! Missing field or invalid characters used!');
57
        }
58
    }
59
}
60