Failed Conditions
Pull Request — master (#3074)
by Sergei
15:08
created

LastInsertId::register()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Doctrine\DBAL\Driver;
4
5
/**
6
 * Last insert ID container.
7
 *
8
 * @author Steve Müller <[email protected]>
9
 */
10
final class LastInsertId
11
{
12
    /**
13
     * @var string
14
     */
15
    private $value = '0';
16
17 33
    public function get() : string
18
    {
19 33
        return $this->value;
20
    }
21
22 268
    public function register(string $value) : void
23
    {
24
        // The last insert ID is reset to "0" in certain situations by some implementations,
25
        // therefore we keep the previously set insert ID locally.
26 268
        if ('0' !== $value) {
27 258
            $this->value = $value;
28
        }
29 268
    }
30
}
31