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

UuidType::convertToDatabaseValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
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