Passed
Push — master ( 6028dd...89a59a )
by Vitaliy
02:15
created

SortHandler::getPriority()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
nc 1
cc 1
eloc 2
nop 0
crap 1
1
<?php
2
3
namespace Nayjest\Querying\Handler\Illuminate;
4
5
use Nayjest\Querying\Handler\AbstractHandler;
6
use Nayjest\Querying\Handler\Priority;
7
use Nayjest\Querying\Operation\SortOperation;
8
use Illuminate\Database\Eloquent\Builder;
9
10
/**
11
 * SortOperation handler for Eloquent.
12
 *
13
 * @see SortOperation
14
 */
15 View Code Duplication
class SortHandler extends AbstractHandler
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17 1
    public function getPriority()
18
    {
19 1
        return Priority::MAIN;
20
    }
21
22
    /**
23
     * Applies operation to data source and returns modified data source.
24
     *
25
     * @param Builder $src
26
     * @return Builder
27
     */
28 1
    public function apply($src)
29
    {
30
        /** @var SortOperation $operation */
31 1
        $operation = $this->operation;
32 1
        $field = $operation->getField();
33 1
        $order = $operation->getOrder();
34 1
        $src->orderBy($field, $order);
35 1
        return $src;
36
    }
37
}
38