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

NullNormalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
dl 0
loc 18
ccs 4
cts 4
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 3 1
A classMethodMap() 0 5 1
1
<?php
2
3
namespace Zenstruck\Porpaginas\Doctrine\ORM\Specification\Normalizer;
4
5
use Zenstruck\Porpaginas\Doctrine\ORM\Specification\ORMContext;
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 ORMNormalizer, ClassMethodMap;
18
19
    /**
20
     * @param Field      $specification
21
     * @param ORMContext $context
22
     */
23 2
    public function normalize($specification, $context): string
24
    {
25 2
        return $context->qb()->expr()->{self::methodFor($specification)}("{$context->alias()}.{$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