Conditions | 4 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
32 | 1 | public function paginate(PaginationParamsInterface $paginationParams, $array) |
|
33 | { |
||
34 | 1 | $paginationParams->setCount(count($array)); |
|
35 | |||
36 | 1 | $count = 1; |
|
37 | 1 | $data = []; |
|
38 | 1 | $offset = $paginationParams->getOffset(); |
|
39 | 1 | $stopAt = $offset + $paginationParams->getLimit(); |
|
40 | |||
41 | 1 | foreach ($array as $key => $value) { |
|
42 | 1 | if ($count > $stopAt) { |
|
43 | 1 | break; |
|
44 | } |
||
45 | |||
46 | 1 | if ($count > $paginationParams->getOffset()) { |
|
47 | 1 | $data[$key] = $value; |
|
48 | } |
||
49 | |||
50 | 1 | $count++; |
|
51 | } |
||
52 | |||
53 | 1 | return $data; |
|
54 | } |
||
56 |