Passed
Push — master ( 647f42...eee75a )
by Wilmer
04:02
created

Connection   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 94.44%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 49
ccs 17
cts 18
cp 0.9444
rs 10
c 0
b 0
f 0
wmc 9

5 Methods

Rating   Name   Duplication   Size   Complexity  
A initConnection() 0 9 4
A createPdoInstance() 0 3 1
A getSchema() 0 3 1
A createCommand() 0 9 2
A getDriverName() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Oracle;
6
7
use PDO;
8
use Yiisoft\Db\Connection\Connection as AbstractConnection;
9
10
/**
11
 * Database connection class prefilled for ORACLE Server.
12
 */
13
final class Connection extends AbstractConnection
14
{
15 164
    public function createCommand(?string $sql = null, array $params = []): Command
16
    {
17 164
        if ($sql !== null) {
18 164
            $sql = $this->quoteSql($sql);
19
        }
20
21 164
        $command = new Command($this, $sql);
22
23 164
        return $command->bindValues($params);
24
    }
25
26
    /**
27
     * Returns the schema information for the database opened by this connection.
28
     *
29
     * @return Schema the schema information for the database opened by this connection.
30
     */
31 305
    public function getSchema(): Schema
32
    {
33 305
        return new Schema($this);
34
    }
35
36 204
    protected function createPdoInstance(): PDO
37
    {
38 204
        return new PDO($this->getDsn(), $this->getUsername(), $this->getPassword(), $this->getAttributes());
39
    }
40
41 204
    protected function initConnection(): void
42
    {
43 204
        $pdo = $this->getPDO();
44
45 204
        if ($pdo !== null) {
46 204
            $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
47
48 204
            if ($this->getEmulatePrepare() !== null && constant('PDO::ATTR_EMULATE_PREPARES')) {
49
                $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, $this->getEmulatePrepare());
50
            }
51
        }
52 204
    }
53
54
    /**
55
     * Returns the name of the DB driver.
56
     *
57
     * @return string name of the DB driver
58
     */
59 7
    public function getDriverName(): string
60
    {
61 7
        return 'oci';
62
    }
63
}
64