Failed Conditions
Pull Request — develop (#3335)
by
unknown
12:47
created

Connection   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 4
dl 0
loc 18
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
lastInsertId() 0 13 ?
A hp$0 ➔ lastInsertId() 0 13 2
1
<?php
2
3
namespace Doctrine\DBAL\Driver\PDOSqlite;
4
5
use Doctrine\DBAL\Driver\AbstractDriverException;
6
use Doctrine\DBAL\Driver\PDOConnection;
7
8
/**
9
 * SQLite Connection implementation.
10
 */
11
class Connection extends PDOConnection
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 4
    public function lastInsertId(?string $name = null): string
17
    {
18 4
        if ($name !== null) {
19
            // SQLite does not support sequences. However, PDO::lastInsertId() ignores the name parameter, and returns
20
            // the last insert ID even if a sequence name is given. We expect an exception in that case.
21
22
            // WIP regarding exceptions, see:
23
            // https://github.com/doctrine/dbal/pull/3335#discussion_r234381175
24
            throw new class ('SQLite does not support sequences.') extends AbstractDriverException {
25
            };
26
        }
27
28 3
        return parent::lastInsertId();
29
    }
30
}
31