Failed Conditions
Push — master ( 4d0d2a...06d1d8 )
by Marco
22s queued 16s
created

Driver::connect()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 13
ccs 10
cts 10
cp 1
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 4
crap 2
1
<?php
2
3
namespace Doctrine\DBAL\Driver\OCI8;
4
5
use Doctrine\DBAL\DBALException;
6
use Doctrine\DBAL\Driver\AbstractOracleDriver;
7
use const OCI_DEFAULT;
8
9
/**
10
 * A Doctrine DBAL driver for the Oracle OCI8 PHP extensions.
11
 */
12
class Driver extends AbstractOracleDriver
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 30
    public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
18
    {
19
        try {
20 30
            return new OCI8Connection(
21 30
                (string) $username,
22 30
                (string) $password,
23 30
                $this->_constructDsn($params),
24 30
                $params['charset'] ?? '',
25 30
                $params['sessionMode'] ?? OCI_DEFAULT,
26 30
                $params['persistent'] ?? false
27
            );
28 3
        } catch (OCI8Exception $e) {
29 3
            throw DBALException::driverException($this, $e);
30
        }
31
    }
32
33
    /**
34
     * Constructs the Oracle DSN.
35
     *
36
     * @param mixed[] $params
37
     *
38
     * @return string The DSN.
39
     */
40 30
    protected function _constructDsn(array $params)
41
    {
42 30
        return $this->getEasyConnectString($params);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 27
    public function getName()
49
    {
50 27
        return 'oci8';
51
    }
52
}
53