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

Driver::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 1
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