Pagination::range PHP Method

range() public method

Creates a range of page numbers for Google-like pagination
public range ( $range = 5 ) : array
return array
    public function range($range = 5)
    {
        if ($this->countPages() <= $range) {
            $this->rangeStart = 1;
            $this->rangeEnd = $this->countPages();
            return range($this->rangeStart, $this->rangeEnd);
        }
        $this->rangeStart = $this->page - (int) floor($range / 2);
        $this->rangeEnd = $this->page + (int) floor($range / 2);
        if ($this->rangeStart <= 0) {
            $this->rangeEnd += abs($this->rangeStart) + 1;
            $this->rangeStart = 1;
        }
        if ($this->rangeEnd > $this->countPages()) {
            $this->rangeStart -= $this->rangeEnd - $this->countPages();
            $this->rangeEnd = $this->countPages();
        }
        return range($this->rangeStart, $this->rangeEnd);
    }