NoRelationHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A filterParameter() 0 10 2
A filterWhereClause() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Bugloos\QueryFilterBundle\FilterHandler;
6
7
use Bugloos\QueryFilterBundle\FilterHandler\Contract\AbstractFilterHandler;
8
use Bugloos\QueryFilterBundle\TypeHandler\Factory\TypeFactory;
9
use ReflectionException;
10
11
/**
12
 * @author Milad Ghofrani <[email protected]>
13
 */
14
class NoRelationHandler extends AbstractFilterHandler
15
{
16
    /**
17
     * @throws ReflectionException
18
     */
19
    public function filterParameter($rootAlias, $rootClass, $relationsAndFieldName, $type): string
20
    {
21
        $alias = $rootAlias;
22
        $field = $relationsAndFieldName[0];
23
24
        $this->validateFieldNames($field, $rootClass);
25
26
        $this->fieldType = $type ?: $this->getFieldTypeFromAnnotation($field, $rootClass);
27
28
        return $this->createParameterName($alias, $field);
29
    }
30
31
    public function filterWhereClause(
32
        $rootAlias,
33
        $relationsAndFieldName,
34
        $filterParameter,
35
        $strategy,
36
        $value
37
    ): string {
38
        $alias = $rootAlias;
39
        $field = $relationsAndFieldName[0];
40
41
        return TypeFactory::createTypeHandler($this->fieldType)
42
            ->filterWhereClause($alias, $field, $filterParameter, $strategy, $value)
43
        ;
44
    }
45
}
46