Conditions | 2 |
Paths | 2 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 2.032 |
Changes | 0 |
1 | <?php |
||
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 |