Completed
Push — 2.10 ( 39b76b...400f60 )
by Sergei
30s queued 15s
created

Driver   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 89.47%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 18
c 1
b 0
f 0
dl 0
loc 47
ccs 17
cts 19
cp 0.8947
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
B connect() 0 32 8
1
<?php
2
3
namespace Doctrine\DBAL\Driver\SQLSrv;
4
5
use Doctrine\DBAL\Driver\AbstractSQLServerDriver;
6
7
/**
8
 * Driver for ext/sqlsrv.
9
 */
10
class Driver extends AbstractSQLServerDriver
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 28
    public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
16
    {
17 28
        if (! isset($params['host'])) {
18
            throw new SQLSrvException("Missing 'host' in configuration for sqlsrv driver.");
19
        }
20
21 28
        $serverName = $params['host'];
22 28
        if (isset($params['port'])) {
23 28
            $serverName .= ', ' . $params['port'];
24
        }
25
26 28
        if (isset($params['dbname'])) {
27 28
            $driverOptions['Database'] = $params['dbname'];
28
        }
29
30 28
        if (isset($params['charset'])) {
31
            $driverOptions['CharacterSet'] = $params['charset'];
32
        }
33
34 28
        if ($username !== null) {
35 28
            $driverOptions['UID'] = $username;
36
        }
37
38 28
        if ($password !== null) {
39 28
            $driverOptions['PWD'] = $password;
40
        }
41
42 28
        if (! isset($driverOptions['ReturnDatesAsStrings'])) {
43 28
            $driverOptions['ReturnDatesAsStrings'] = 1;
44
        }
45
46 28
        return new SQLSrvConnection($serverName, $driverOptions);
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     *
52
     * @deprecated
53
     */
54 54
    public function getName()
55
    {
56 54
        return 'sqlsrv';
57
    }
58
}
59