PDOStorage::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
eloc 2
nc 1
nop 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 30 and the first side effect is on line 18.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
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