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

PaginateHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 21
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPriority() 0 4 1
A apply() 0 7 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