Completed
Push — master ( 4030be...df6e71 )
by Tobias
10:01
created

ValueConverter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A convertToDatabaseValue() 0 11 2
1
<?php
2
3
namespace Happyr\DoctrineSpecification;
4
5
use Doctrine\ORM\QueryBuilder;
6
7
final class ValueConverter
8
{
9
    /**
10
     * @param mixed        $value
11
     * @param QueryBuilder $qb
12
     *
13
     * @return mixed
14
     */
15
    public static function convertToDatabaseValue($value, QueryBuilder $qb)
16
    {
17
        if ($type = DBALTypesResolver::tryGetTypeForValue($value)) {
18
            return $type->convertToDatabaseValue(
19
                $value,
20
                $qb->getEntityManager()->getConnection()->getDatabasePlatform()
21
            );
22
        }
23
24
        return $value;
25
    }
26
}
27