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

BigIntegerIdentityGenerator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 3 1
A isPostInsertGenerator() 0 3 1
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