Completed
Pull Request — 3.x (#547)
by Jeroen
02:29
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\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