Conditions | 4 |
Paths | 6 |
Total Lines | 17 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
51 | public static function adjustCountForPaging(int $count, ?int $top, ?int $skip) |
||
52 | { |
||
53 | //treat nulls like 0 |
||
54 | if (null === $skip) { |
||
55 | $skip = 0; |
||
56 | } |
||
57 | |||
58 | $count = $count - $skip; //eliminate the skipped records |
||
59 | if ($count < 0) { |
||
60 | return 0; |
||
61 | } //if there aren't enough to skip, the count is 0 |
||
62 | |||
63 | if (null === $top) { |
||
64 | return $count; |
||
65 | } //if there's no top, then it's the count as is |
||
66 | |||
67 | return intval(min($count, $top)); //count is top, unless there aren't enough records |
||
68 | } |
||
70 |