ValueConverter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
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
/**
4
 * This file is part of the Happyr Doctrine Specification package.
5
 *
6
 * (c) Tobias Nyholm <[email protected]>
7
 *     Kacper Gunia <[email protected]>
8
 *     Peter Gribanov <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Happyr\DoctrineSpecification;
15
16
use Doctrine\ORM\QueryBuilder;
17
18
final class ValueConverter
19
{
20
    /**
21
     * @param mixed        $value
22
     * @param QueryBuilder $qb
23
     *
24
     * @return mixed
25
     */
26
    public static function convertToDatabaseValue($value, QueryBuilder $qb)
27
    {
28
        if ($type = DBALTypesResolver::tryGetTypeForValue($value)) {
29
            return $type->convertToDatabaseValue(
30
                $value,
31
                $qb->getEntityManager()->getConnection()->getDatabasePlatform()
32
            );
33
        }
34
35
        return $value;
36
    }
37
}
38