Failed Conditions
Push — master ( fa7802...d60694 )
by Guilherme
09:27
created

BigIntegerIdentityGenerator::generate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Sequencing\Generator;
6
7
use Doctrine\ORM\EntityManagerInterface;
8
9
/**
10
 * Id generator that obtains IDs from special "identity" columns. These are columns
11
 * that automatically get a database-generated, auto-incremented identifier on INSERT.
12
 * This generator obtains the last insert id after such an insert.
13
 */
14
class BigIntegerIdentityGenerator implements Generator
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19 3
    public function generate(EntityManagerInterface $em, ?object $entity)
20
    {
21 3
        return (string) $em->getConnection()->lastInsertId();
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 3
    public function isPostInsertGenerator() : bool
28
    {
29 3
        return true;
30
    }
31
}
32