Failed Conditions
Pull Request — develop (#3518)
by Michael
29:00 queued 25:29
created

Driver::connect()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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