Completed
Pull Request — 3.x (#928)
by
unknown
01:37
created

UuidBinaryType::convertToDatabaseValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\DoctrineORMAdminBundle\Tests\Fixtures\DoctrineType;
13
14
use Doctrine\DBAL\Platforms\AbstractPlatform;
15
use Doctrine\DBAL\Types\StringType;
16
use Sonata\DoctrineORMAdminBundle\Tests\Fixtures\Util\NonIntegerIdentifierTestClass;
17
18
/**
19
 * Mock for a custom doctrine type used in the ModelManagerTest suite.
20
 *
21
 * @author Jorge Garces <[email protected]>
22
 */
23
final class UuidBinaryType extends StringType
24
{
25
    const NAME = 'uuid_binary';
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function getName()
31
    {
32
        return self::NAME;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function convertToPHPValue($value, AbstractPlatform $platform)
39
    {
40
        return !empty($value) ? new NonIntegerIdentifierTestClass($value->toString()) : null;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
47
    {
48
        return $value->toString();
49
    }
50
}
51