Passed
Push — master ( 2b2b59...ef2215 )
by Wilmer
04:20
created

Driver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 16
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createConnection() 0 9 2
A getDriverName() 0 3 1
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 282
    public function createConnection(): PDO
18
    {
19 282
        $this->attributes += [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
20
21 282
        if (PHP_VERSION_ID >= 80100) {
22
            $this->attributes += [PDO::ATTR_STRINGIFY_FETCHES => true];
23
        }
24
25 282
        return parent::createConnection();
26
    }
27
28 354
    public function getDriverName(): string
29
    {
30 354
        return 'sqlite';
31
    }
32
}
33