Passed
Push — master ( 6137ca...01151b )
by Kevin
02:21
created

NullNormalizer::classMethodMap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Zenstruck\Porpaginas\Doctrine\DBAL\Specification\Normalizer;
4
5
use Zenstruck\Porpaginas\Doctrine\DBAL\Specification\DBALContext;
6
use Zenstruck\Porpaginas\Specification\Field;
7
use Zenstruck\Porpaginas\Specification\Filter\IsNotNull;
8
use Zenstruck\Porpaginas\Specification\Filter\IsNull;
9
use Zenstruck\Porpaginas\Specification\Normalizer;
10
use Zenstruck\Porpaginas\Specification\Normalizer\ClassMethodMap;
11
12
/**
13
 * @author Kevin Bond <[email protected]>
14
 */
15
final class NullNormalizer implements Normalizer
16
{
17
    use DBALNormalizer, ClassMethodMap;
18
19
    /**
20
     * @param Field       $specification
21
     * @param DBALContext $context
22
     */
23 2
    public function normalize($specification, $context): string
24
    {
25 2
        return $context->qb()->expr()->{self::methodFor($specification)}($specification->field());
26
    }
27
28 3
    protected static function classMethodMap(): array
29
    {
30
        return [
31 3
            IsNull::class => 'isNull',
32
            IsNotNull::class => 'isNotNull',
33
        ];
34
    }
35
}
36