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

PaginateHandler::apply()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
nc 1
cc 1
eloc 4
nop 1
crap 1
1
<?php
2
3
namespace Nayjest\Querying\Handler\Illuminate;
4
5
use Nayjest\Querying\Handler\AbstractPaginateHandler;
6
use Nayjest\Querying\Handler\Priority;
7
use Nayjest\Querying\Operation\PaginateOperation;
8
use Illuminate\Database\Eloquent\Builder;
9
10
/**
11
 * PaginateOperation processing for DoctrineDataProvider.
12
 *
13
 * @see PaginateOperation
14
 */
15
class PaginateHandler extends AbstractPaginateHandler
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 PaginateOperation $operation */
31 1
        $operation = $this->operation;
32 1
        return $src->limit($operation->getPageSize())
33 1
            ->offset($this->getOffset($operation));
34
    }
35
}
36