DoctrineObject   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handleTypeConversions() 0 11 3
1
<?php
2
3
namespace JhFlexiTime\Stdlib\Hydrator;
4
5
use DoctrineModule\Stdlib\Hydrator\DoctrineObject as BaseDoctrineObject;
6
use Doctrine\DBAL\Types\Type;
7
8
/**
9
 * This class allows the Doctrine Hydrator to delegate
10
 * type conversion to the custom Type, if it implements TypeConversionInterface
11
 *
12
 * Class DoctrineObject
13
 * @package JhFlexiTime\Stdlib\Hydrator
14
 * @author Aydin Hassan <[email protected]>
15
 */
16
class DoctrineObject extends BaseDoctrineObject
17
{
18
    /**
19
     * @param mixed $value
20
     * @param string $typeOfField
21
     * @return mixed
22
     */
23
    protected function handleTypeConversions($value, $typeOfField)
24
    {
25
        if (Type::hasType($typeOfField)) {
26
            $type = Type::getType($typeOfField);
27
            if ($type instanceof TypeConversionInterface) {
28
                return $type->convertToHydratorValue($value);
29
            }
30
        }
31
32
        return parent::handleTypeConversions($value, $typeOfField);
33
    }
34
}
35