| Conditions | 5 |
| Paths | 6 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | 9 | protected function getDisplayPages(): array |
|
| 25 | { |
||
| 26 | 9 | $actualPage = $this->getPositions()->getPager()->getActualPage(); // 2 |
|
| 27 | 9 | $count = $this->getPositions()->getPager()->getPagesCount(); // 20 |
|
| 28 | 9 | $whole = $this->displayPagesCount; // 10 |
|
| 29 | |||
| 30 | 9 | $half = floor($whole / 2); // 5 |
|
| 31 | 9 | $tail = $count - $actualPage; // 18 |
|
| 32 | |||
| 33 | 9 | $i = ($tail > $half) ? intval($actualPage - $half) : intval($count - $whole + 1); // 3 |
|
| 34 | 9 | $result = []; |
|
| 35 | |||
| 36 | // ++ < 10 && 3 <= 20 |
||
| 37 | 9 | while ((count($result) < $this->displayPagesCount) && ($i <= $count)) { |
|
| 38 | 9 | if ($this->getPositions()->getPager()->pageExists($i)) { |
|
| 39 | 9 | $result[] = $i; |
|
| 40 | } |
||
| 41 | 9 | $i++; |
|
| 42 | } |
||
| 43 | |||
| 44 | 9 | return $result; |
|
| 45 | } |
||
| 47 |