OneLevelRelationHandler::getRelationJoin()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 5
rs 10
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