Passed
Push — 2.9 ( d389f3...7345cd )
by Sergei
31:44 queued 28:51
created

Driver   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 13.33%

Importance

Changes 0
Metric Value
wmc 5
eloc 14
dl 0
loc 43
ccs 2
cts 15
cp 0.1333
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A connect() 0 11 2
A getName() 0 3 1
A constructPdoDsn() 0 9 2
1
<?php
2
3
namespace Doctrine\DBAL\Driver\PDOOracle;
4
5
use Doctrine\DBAL\DBALException;
6
use Doctrine\DBAL\Driver\AbstractOracleDriver;
7
use Doctrine\DBAL\Driver\PDOConnection;
8
use PDOException;
9
10
/**
11
 * PDO Oracle driver.
12
 *
13
 * WARNING: This driver gives us segfaults in our testsuites on CLOB and other
14
 * stuff. PDO Oracle is not maintained by Oracle or anyone in the PHP community,
15
 * which leads us to the recommendation to use the "oci8" driver to connect
16
 * to Oracle instead.
17
 */
18
class Driver extends AbstractOracleDriver
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
24
    {
25
        try {
26
            return new PDOConnection(
27
                $this->constructPdoDsn($params),
28
                $username,
29
                $password,
30
                $driverOptions
31
            );
32
        } catch (PDOException $e) {
33
            throw DBALException::driverException($this, $e);
34
        }
35
    }
36
37
    /**
38
     * Constructs the Oracle PDO DSN.
39
     *
40
     * @param mixed[] $params
41
     *
42
     * @return string The DSN.
43
     */
44
    private function constructPdoDsn(array $params)
45
    {
46
        $dsn = 'oci:dbname=' . $this->getEasyConnectString($params);
47
48
        if (isset($params['charset'])) {
49
            $dsn .= ';charset=' . $params['charset'];
50
        }
51
52
        return $dsn;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 30
    public function getName()
59
    {
60 30
        return 'pdo_oracle';
61
    }
62
}
63