PaginateHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 24
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPriority() 0 4 1
A apply() 0 16 2
1
<?php
2
3
namespace Nayjest\Querying\Handler\PostProcess;
4
5
use Nayjest\Querying\Handler\AbstractPaginateHandler;
6
use Nayjest\Querying\Handler\Priority;
7
use Nayjest\Querying\Operation\PaginateOperation;
8
9
class PaginateHandler extends AbstractPaginateHandler
10
{
11 1
    public function getPriority()
12
    {
13 1
        return Priority::POST_PROCESS - 4;
14
    }
15
16 1
    public function apply($dataSource)
17
    {
18
        /** @var PaginateOperation $operation */
19 1
        $operation = $this->operation;
20
        /**
21
         * @todo optimise for generators
22
         */
23 1
        if (!is_array($dataSource)) {
24
            $dataSource = iterator_to_array($dataSource);
25
        }
26 1
        return array_slice(
27 1
            $dataSource,
28 1
            $this->getOffset($operation),
29 1
            $operation->getPageSize()
30 1
        );
31
    }
32
}
33