Driver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 17
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDriverName() 0 3 1
A createConnection() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Pgsql;
6
7
use PDO;
8
use Yiisoft\Db\Driver\Pdo\AbstractPdoDriver;
9
10
/**
11
 * Implements the PostgreSQL Server driver based on the PDO (PHP Data Objects) extension.
12
 *
13
 * @link https://www.php.net/manual/en/ref.pdo-pgsql.php
14
 */
15
final class Driver extends AbstractPdoDriver
16
{
17 312
    public function createConnection(): PDO
18
    {
19 312
        $this->attributes += [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
20 312
        $pdo = parent::createConnection();
21
22 312
        if ($this->charset !== null) {
23 311
            $pdo->exec('SET NAMES ' . $pdo->quote($this->charset));
24
        }
25
26 312
        return $pdo;
27
    }
28
29 448
    public function getDriverName(): string
30
    {
31 448
        return 'pgsql';
32
    }
33
}
34