Failed Conditions
Pull Request — develop (#3581)
by Jonathan
12:44
created

Driver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 54.55%

Importance

Changes 0
Metric Value
wmc 3
eloc 12
dl 0
loc 35
ccs 12
cts 22
cp 0.5455
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A connect() 0 17 2
A _constructDsn() 0 3 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 Doctrine\DBAL\Driver\Connection;
10
use const OCI_DEFAULT;
11
12
/**
13
 * A Doctrine DBAL driver for the Oracle OCI8 PHP extensions.
14
 */
15
class Driver extends AbstractOracleDriver
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 29
    public function connect(
21
        array $params,
22
        string $username = '',
23
        string $password = '',
24
        array $driverOptions = []
25
    ) : Connection {
26
        try {
27 29
            return new OCI8Connection(
28 29
                $username,
29 29
                $password,
30 29
                $this->_constructDsn($params),
31 29
                $params['charset'] ?? '',
32 29
                $params['sessionMode'] ?? OCI_DEFAULT,
33 29
                $params['persistent'] ?? false
34
            );
35 3
        } catch (OCI8Exception $e) {
36 3
            throw DBALException::driverException($this, $e);
37
        }
38
    }
39
40
    /**
41
     * Constructs the Oracle DSN.
42
     *
43
     * @param mixed[] $params
44
     *
45
     * @return string The DSN.
46
     */
47 29
    protected function _constructDsn(array $params) : string
48
    {
49 29
        return $this->getEasyConnectString($params);
50
    }
51
}
52