OneLevelRelationHandler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRelationJoin() 0 5 1
A getSortProperty() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Bugloos\QuerySortingBundle\SortingHandler;
6
7
use Bugloos\QuerySortingBundle\SortingHandler\Contract\AbstractSortingHandler;
8
use Bugloos\QuerySortingBundle\SortingHandler\Contract\WithRelationInterface;
9
10
/**
11
 * @author Milad Ghofrani <[email protected]>
12
 */
13
class OneLevelRelationHandler extends AbstractSortingHandler implements WithRelationInterface
14
{
15
    public function getSortProperty($rootAlias, $rootClass, $relationsAndFieldName): string
16
    {
17
        [$relationAlias, $relationField] = $relationsAndFieldName;
18
19
        $this->validateRelationNames($relationAlias, $rootClass);
20
21
        $relationClass = $this->getRelationClass($rootClass, $relationAlias);
22
        $this->validateFieldNames($relationField, $relationClass);
23
24
        return $this->createOrderBySyntax($relationAlias, $relationField);
25
    }
26
27
    public function getRelationJoin($relationJoins, $rootAlias, $rootClass, $relationsAndFieldName): array
28
    {
29
        [$relationAlias] = $relationsAndFieldName;
30
31
        return $this->addRelationJoin($relationJoins, $rootAlias, $relationAlias);
32
    }
33
}
34