Driver::createConnection()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Sqlite;
6
7
use PDO;
8
use Yiisoft\Db\Driver\Pdo\AbstractPdoDriver;
9
10
/**
11
 * Implements the SQLite Server driver based on the PDO (PHP Data Objects) extension.
12
 *
13
 * @link https://www.php.net/manual/en/ref.pdo-sqlite.php
14
 */
15
final class Driver extends AbstractPdoDriver
16
{
17 303
    public function createConnection(): PDO
18
    {
19 303
        $this->attributes += [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
20
21 303
        if (PHP_VERSION_ID >= 80100) {
22 303
            $this->attributes += [PDO::ATTR_STRINGIFY_FETCHES => true];
23
        }
24
25 303
        return parent::createConnection();
26
    }
27
28 413
    public function getDriverName(): string
29
    {
30 413
        return 'sqlite';
31
    }
32
}
33