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

ValueConverter::convertToDatabaseValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 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