Failed Conditions
Push — master ( ddb3cd...4476ec )
by Marco
11:47
created

UuidGenerator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 6 1
A isPostInsertGenerator() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\ORM\Sequencing;
6
7
use Doctrine\ORM\EntityManagerInterface;
8
9
/**
10
 * Represents an ID generator that uses the database UUID expression
11
 */
12
class UuidGenerator implements Generator
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function generate(EntityManagerInterface $em, $entity)
18
    {
19
        $conn = $em->getConnection();
20
        $sql  = 'SELECT ' . $conn->getDatabasePlatform()->getGuidExpression();
21
22
        return $conn->query($sql)->fetchColumn(0);
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function isPostInsertGenerator()
29
    {
30
        return false;
31
    }
32
}
33