Completed
Pull Request — 3.x (#547)
by Jeroen
03:45 queued 01:10
created

UuidType::getName()   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 0
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\Model\Uuid;
8
9
class UuidType extends StringType
10
{
11
    const NAME = 'uuid';
12
13
    public function getName()
14
    {
15
        return self::NAME;
16
    }
17
    /**
18
     * {@inheritDoc}
19
     */
20
    public function convertToPHPValue($value, AbstractPlatform $platform)
21
    {
22
        return !empty($value) ? new Uuid($value) : null;
23
    }
24
    /**
25
     * {@inheritDoc}
26
     */
27
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
28
    {
29
        return $value->toString();
30
    }
31
}
32