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

Mysql   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A connect() 0 21 1
1
<?php
2
namespace WebStream\Database\Driver;
3
4
use Doctrine\DBAL\Configuration;
5
use Doctrine\DBAL\DriverManager;
6
7
/**
8
 * Mysql
9
 * @author Ryuichi TANAKA.
10
 * @since 2013/12/07
11
 * @version 0.4
12
 */
13
class Mysql extends DatabaseDriver
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 21
    public function connect()
19
    {
20
        $params = [
21 21
            'dbname'   => $this->config->dbname,
22 21
            'user'     => $this->config->username,
23 21
            'password' => $this->config->password,
24 21
            'host'     => $this->config->host,
25 21
            'port'     => $this->config->port,
26 21
            'driver'   => 'pdo_mysql',
27 21
            'charset'  => 'utf8'
28
        ];
29
30 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...BUFFERED_QUERY => true). ( Ignorable by Annotation )

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

30
        $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...
31 21
            \PDO::ATTR_PERSISTENT => true,
32
            \PDO::ATTR_EMULATE_PREPARES => false,
33 21
            \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
34
            \PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
35
        ]);
36
37 21
        $this->connection = DriverManager::getConnection($params, $config);
38 21
        $this->logger->debug(get_class($this) . " connect.");
39
    }
40
}
41