Failed Conditions
Pull Request — 3.0.x (#3980)
by Guilherme
07:55
created

DB2Driver::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
namespace Doctrine\DBAL\Driver\IBMDB2;
4
5
use Doctrine\DBAL\Driver\AbstractDB2Driver;
6
7
/**
8
 * IBM DB2 Driver.
9
 */
10
class DB2Driver extends AbstractDB2Driver
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
16
    {
17
        if (! isset($params['protocol'])) {
18
            $params['protocol'] = 'TCPIP';
19
        }
20
21
        if ($params['host'] !== 'localhost' && $params['host'] !== '127.0.0.1') {
22
            // if the host isn't localhost, use extended connection params
23
            $params['dbname'] = 'DRIVER={IBM DB2 ODBC DRIVER}' .
24
                     ';DATABASE=' . $params['dbname'] .
25
                     ';HOSTNAME=' . $params['host'] .
26
                     ';PROTOCOL=' . $params['protocol'] .
27
                     ';UID=' . $username .
28
                     ';PWD=' . $password . ';';
29
            if (isset($params['port'])) {
30
                $params['dbname'] .= 'PORT=' . $params['port'];
31
            }
32
33
            $username = null;
34
            $password = null;
35
        }
36
37
        return new DB2Connection($params, (string) $username, (string) $password, $driverOptions);
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     *
43
     * @deprecated
44
     */
45 22
    public function getName()
46
    {
47 22
        return 'ibm_db2';
48
    }
49
}
50