Passed
Push — master ( ed8dd1...b26a3b )
by Ryuichi
03:11
created

Sqlite::connect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 11
nc 1
nop 0
dl 0
loc 17
ccs 11
cts 11
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace WebStream\Database\Driver;
3
4
use Doctrine\DBAL\Configuration;
5
use Doctrine\DBAL\DriverManager;
6
7
/**
8
 * Sqlite
9
 * @author Ryuichi TANAKA.
10
 * @since 2013/12/07
11
 * @version 0.4
12
 */
13
class Sqlite extends DatabaseDriver
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 21
    public function connect()
19
    {
20
        $params = [
21 21
            'path'     => $this->config->dbfile,
22 21
            'user'     => $this->config->username,
23 21
            'password' => $this->config->password,
24 21
            'driver'   => 'pdo_sqlite',
25 21
            'charset'  => 'utf8'
26
        ];
27
28 21
        $config = new Configuration([
0 ignored issues
show
Unused Code introduced by
The call to Doctrine\DBAL\Configuration::__construct() has too many arguments starting with array(PDO::ATTR_PERSISTE...PDO::ERRMODE_EXCEPTION). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $config = /** @scrutinizer ignore-call */ new Configuration([

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
29 21
            \PDO::ATTR_PERSISTENT => true,
30 21
            \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION
31
        ]);
32
33 21
        $this->connection = DriverManager::getConnection($params, $config);
34 21
        $this->logger->debug(get_class($this) . " connect.");
35
    }
36
}
37