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

Driver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 14.29%

Importance

Changes 0
Metric Value
wmc 4
eloc 13
dl 0
loc 39
ccs 2
cts 14
cp 0.1429
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A connect() 0 13 2
A _constructDsn() 0 3 1
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
    public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
18
    {
19
        try {
20
            return new OCI8Connection(
21
                $username,
22
                $password,
23
                $this->_constructDsn($params),
24
                $params['charset'] ?? null,
25
                $params['sessionMode'] ?? OCI_DEFAULT,
26
                $params['persistent'] ?? false
27
            );
28
        } catch (OCI8Exception $e) {
29
            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
    protected function _constructDsn(array $params)
41
    {
42
        return $this->getEasyConnectString($params);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 30
    public function getName()
49
    {
50 30
        return 'oci8';
51
    }
52
}
53