Failed Conditions
Pull Request — develop (#3367)
by Benjamin
10:59
created

Connection::lastInsertId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 9
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Doctrine\DBAL\Driver\PDOSqlite;
4
5
use Doctrine\DBAL\Driver\DriverException;
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 1
            throw new DriverException('SQLite does not support sequences.');
22
        }
23
24 3
        return parent::lastInsertId();
25
    }
26
}
27