Completed
Pull Request — 3.x (#547)
by Jeroen
02:34
created

UuidType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 23
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A convertToPHPValue() 0 4 2
A convertToDatabaseValue() 0 4 1
1
<?php
2
3
namespace Sonata\DoctrineORMAdminBundle\Tests\Fixtures\DoctrineType;
4
5
use Doctrine\DBAL\Platforms\AbstractPlatform;
6
use Doctrine\DBAL\Types\StringType;
7
use Sonata\DoctrineORMAdminBundle\Tests\Fixtures\Util\NonIntegerIdentifierTestClass;
8
9
/**
10
 * Mock for a custom doctrine type used in the ModelManagerTest suite
11
 *
12
 * @author Jeroen Thora <[email protected]>
13
 */
14
class UuidType extends StringType
15
{
16
    const NAME = 'uuid';
17
18
    public function getName()
19
    {
20
        return self::NAME;
21
    }
22
    /**
23
     * {@inheritDoc}
24
     */
25
    public function convertToPHPValue($value, AbstractPlatform $platform)
26
    {
27
        return !empty($value) ? new NonIntegerIdentifierTestClass($value) : null;
28
    }
29
    /**
30
     * {@inheritDoc}
31
     */
32
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
33
    {
34
        return $value->toString();
35
    }
36
}
37