Version   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 41
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A getSQLDeclaration() 0 7 2
A convertToDatabaseValue() 0 4 2
A convertToPHPValue() 0 4 2
1
<?php
2
3
namespace kujaff\VersionsBundle\Type;
4
5
use Doctrine\DBAL\Platforms\AbstractPlatform;
6
use Doctrine\DBAL\Types\Type;
7
use \kujaff\VersionsBundle\Entity\Version as VersionEntity;
8
9
/**
10
 * Field base64 encoded value
11
 */
12
class Version extends Type
13
{
14
    const VERSION = 'version';
15
16
    /**
17
     * Return type name
18
     *
19
     * @return type
20
     */
21
    public function getName()
22
    {
23
        return self::VERSION;
24
    }
25
26
    /**
27
     * {@inherited}
28
     */
29
    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
30
    {
31
        if (!array_key_exists('length', $fieldDeclaration)) {
32
            $fieldDeclaration['length'] = 10;
33
        }
34
        return 'VARCHAR(' . intval($fieldDeclaration['length']) . ')';
35
    }
36
37
    /**
38
     * {@inherited}
39
     */
40
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
41
    {
42
        return ($value === null) ? null : $value->asString();
43
    }
44
45
    /**
46
     * {@inherited}
47
     */
48
    public function convertToPHPValue($value, AbstractPlatform $platform)
49
    {
50
        return ($value === null) ? null : new VersionEntity($value);
51
    }
52
}
53