Failed Conditions
Pull Request — master (#3074)
by Sergei
12:41
created

LastInsertId   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A register() 0 9 2
1
<?php
2
3
namespace Doctrine\DBAL\Driver;
4
5
/**
6
 * Last insert ID container.
7
 */
8
final class LastInsertId
9
{
10
    /** @var int */
11
    private $value = 0;
12
13
    public function get() : int
14
    {
15
        return $this->value;
16
    }
17
18
    public function register(int $value) : void
19
    {
20
        // The last insert ID is reset to 0 in certain situations by some implementations,
21
        // therefore we keep the previously set insert ID locally.
22
        if ($value === 0) {
23
            return;
24
        }
25
26
        $this->value = $value;
27
    }
28
}
29