Extract pagination values
@return array
324512
protected function extractPagination()
    {
        Logger::log(static::class . ' extract pagination start', LOG_DEBUG);
        $page = array_key_exists(self::API_PAGE_FIELD, $this->query) ? $this->query[self::API_PAGE_FIELD] : 1;
        $limit = array_key_exists(self::API_LIMIT_FIELD, $this->query) ? $this->query[self::API_LIMIT_FIELD] : 100;
        Logger::log(static::class . ' extract pagination end', LOG_DEBUG);
        return array($page, (int)$limit);
    }
229005
public function get()
    {
        if ($this->page_count <= 1) {
            return '';
        }

        // Output HTML holder.
        $output = '';

        $output .= $this->get_opening_links();
        $output .= $this->get_links();
        $output .= $this->get_closing_links();

        // Apply before and after content if present in the args.
        if (! empty($output)) {
            $output = $this->args['before_output'] . $output . $this->args['after_output'];
        }

        /**
         * Filter snap_pagination output.
         *
         * @since  1.0.0
         *
         * @var string $output The output HTML for the pagination.
         * @return  string The filtered HTML.
         */
        $output = apply_filters('snap_pagination_output', $output);

        return $output;
    }
704718
private function getFromTo(): array
    {
        if ($this->count < $this->perPage || $this->perPage === null) {
            $start = 1;
            $end = $this->count;
        } else {
            if ($this->hasMorePages()) {
                $end = $this->perPage * $this->currentPage;
                $start = ($end - $this->perPage) + 1;
            } else {
                $endTest = $this->perPage * $this->currentPage;
                $start = ($endTest - $this->perPage) + 1;

                $end = $start + $this->getCountOnLastPage();
            }
        }

        return ['from' => $start, 'to' => $end];
    }
1199426
protected function extractRows()
    {
        $source = $this->source;

        // Laravel query builder case
        if(  $this->isSourceQueryBuilder())  {
            /** @var $source \Illuminate\Database\Query\Builder */

            $count = query(raw("({$source->toSql()}) as a"), [raw('COUNT(*) as _num_rows')], $source->getConnection()->getName())->mergeBindings($source)->first();
            $this->itemsTotal = isset($count['_num_rows']) ?  $count['_num_rows'] : null;

            $source = $source->skip($this->getItemsOffset())->take($this->getItemsPerPage())->get();
            $source = new \ArrayIterator($source);

            // Array case
        } elseif(is_array($source)) {
            $this->itemsTotal = count($source);
            $source = array_slice($source, $this->getItemsOffset(), $this->getItemsPerPage());
            $source = new \ArrayIterator($source);
        }

        /**@var $source \Iterator */
        if (!($source instanceof \Iterator)) {
            throw new \InvalidArgumentException("Source must be an array or an Iterator");
        }


        if (!is_null($source)) {
            $this->setRows($source);

            if ($this->hasJsonField()) {
                $this->extractJson();
            }
        }

        return $this;
    }
545130
private function getPaginationIndex($optionsPagination = array())
    {
        $nbResult = 0;
        $nbPages = 0;
        $currentPage = 0;
        $nextPage = 0;
        $previousPage = 0;
        $nbResultPerPage = 10;
        $offset = 4;
        $indexToDisplay = array();

        //Setting vars
        if (isset($optionsPagination['nbResult'])) {
            $nbResult =$optionsPagination['nbResult'];
        }
        if (isset($optionsPagination['nbPages'])) {
            $nbPages = $optionsPagination['nbPages'];
        }
        if (isset($optionsPagination['currentPage'])) {
            $currentPage = $optionsPagination['currentPage'];
        }
        if (isset($optionsPagination['nextPage'])) {
            $nextPage = $optionsPagination['nextPage'];
        }
        if (isset($optionsPagination['previousPage'])) {
            $previousPage = $optionsPagination['previousPage'];
        }
        if (isset($optionsPagination['nbResultPerPage'])) {
            $nbResultPerPage = $optionsPagination['nbResultPerPage'];
        }
        if (isset($optionsPagination['offset'])) {
            $offset = $optionsPagination['offset'];
        }

        //Processing firstpage index
        if ($nbPages<=(2*$offset+1)) {
            $indexToDisplay['firstPage'] = 0;
            $indexToDisplay['lastPage'] = $nbPages-1;
        } else {
            if (($currentPage - $offset)<= 0) {
                $indexToDisplay['firstPage'] = 0;
            } else {
                $indexToDisplay['firstPage'] = $currentPage - $offset - 1;
            }

            //Processing lastpage index
            if (($currentPage+$offset)>=$nbPages) {
                $indexToDisplay['lastPage'] = $nbPages-1;
            } else {
                $indexToDisplay['lastPage']=$currentPage+$offset-1;
            }

            // Adjusting first page index or last page index if nb of previous pages are not balanced compared to next ones
            // Adding the extra missing page to a side or another to really have 9 pages (aka 2*offset+1)
            if ((2*$offset+1) > ($indexToDisplay['lastPage'] - $indexToDisplay['firstPage'] )) {
                //Calculating the offset to add to first or last page
                $offsetAdd=(2*$offset+1) - ($indexToDisplay['lastPage'] - $indexToDisplay['firstPage'] );

                if ($indexToDisplay['firstPage'] == 0) {
                    $indexToDisplay['lastPage']+=$offsetAdd-1;
                } else {
                    $indexToDisplay['firstPage']-=$offsetAdd-1;
                }
            }
        }

        $indexRange = array();
        for ($i = $indexToDisplay['firstPage']; $i <= $indexToDisplay['lastPage']; $i++) {
            $indexRange[] = $i;
        }
        $indexToDisplay['range'] = $indexRange;
        return $indexRange;
    }
727448
public function getValue()
    {
        $values = array();
        foreach (array_keys($this->pages) as $id) {
            $pageValues = $this->getSessionContainer()->getValues($id);
            // skip elements representing actions
            foreach ($pageValues as $key => $value) {
                if (0 !== strpos($key, '_qf')) {
                    if (isset($values[$key]) && is_array($value)) {
                        $values[$key] = self::arrayMerge($values[$key], $value);
                    } else {
                        $values[$key] = $value;
                    }
                }
            }
        }
        return $values;
    }
1012504
public function getPages(Paginator $paginator, $pageRange = null)
    {
        if ($pageRange === null) {
            $pageRange = $paginator->getPageRange();
        }

        $pageNumber = $paginator->getCurrentPageNumber();
        $pageCount  = count($paginator);

        if ($pageRange > $pageCount) {
            $pageRange = $pageCount;
        }

        $delta = ceil($pageRange / 2);

        if ($pageNumber - $delta > $pageCount - $pageRange) {
            $lowerBound = $pageCount - $pageRange + 1;
            $upperBound = $pageCount;
        } else {
            if ($pageNumber - $delta < 0) {
                $delta = $pageNumber;
            }

            $offset     = $pageNumber - $delta;
            $lowerBound = $offset + 1;
            $upperBound = $offset + $pageRange;
        }

        return $paginator->getPagesInRange($lowerBound, $upperBound);
    }
904413
public function getQueryString()
    {
        $query = [];
        if (!empty($this->pagination)) {
            $query[self::PARAM_PAGINATION] = $this->pagination;
        }
        if (!empty($this->filters)) {
            $query[self::PARAM_FILTERING] = $this->filters;
        }
        foreach ($this->fields as $modelType => $fields) {
            $query[self::PARAM_FIELDSETS][$modelType] = implode(',', $fields);
        }
        $sort = [];
        foreach ($this->sorting as $key => $direction) {
            $sort[] = (1 === $direction) ? $key : sprintf('-%s', $key);
        }
        if (!empty($sort)) {
            $query[self::PARAM_SORTING] = implode(',', $sort);
        }
        return http_build_query($query);
    }
11300
public function getArrayCopy()
    {
        $results = array_map(function ($entity) {
            return $entity->getArrayCopy();
        }, $this->entities);

        if (! $this->paginationData) {
            return $results;
        } else {
            $data = $this->paginationData->getArrayCopy();
            $data['results'] = $results;
            return $data;
        }
    }
985052
public function getPaginationBar() {
		
		if (is_null($this->pagination->count)) {
			$this->logError('The “count” parameter needed for pagination has not been set');
		}
		
		return $this->pagination->render();
		
	}
130974
public function getPagination()
    {
        $limit = $this->userManager->getUsersLimit();
        $count = $this->countVisibleUsers();
        $pages = $count / $limit;
        $remainder = $count % $limit;
        if ($remainder === 0) {
            return $pages;
        } else {
            return floor($pages) + 1;
        }
    }
851038
public function getLimits()
    {
        $totalPages = $this->getTotalPages();

        $this->currentPage = ($this->currentPage > $totalPages) ? $totalPages : $this->currentPage;

        $dLimit = ($this->currentPage - 1) * $this->itemsPerPage;

        return array($dLimit, $this->itemsPerPage);
    }
1029435
public function pageInfoResolver(LengthAwarePaginator $paginator): array
    {
        return [
            'total' => $paginator->total(),
            'count' => $paginator->count(),
            'currentPage' => $paginator->currentPage(),
            'lastPage' => $paginator->lastPage(),
            'hasNextPage' => $paginator->hasMorePages(),
            'hasPreviousPage' => $paginator->currentPage() > 1,
            'startCursor' => $paginator->firstItem()
                ? Cursor::encode($paginator->firstItem())
                : null,
            'endCursor' => $paginator->lastItem()
                ? Cursor::encode($paginator->lastItem())
                : null,
        ];
    }
30028
protected function fetchData()
	{
		if(($sort=$this->getSort())!==false && ($order=$sort->getOrderBy())!='')
			$this->sortData($this->getSortDirections($order));

		if(($pagination=$this->getPagination())!==false)
		{
			$pagination->setItemCount($this->getTotalItemCount());
			return array_slice($this->rawData, $pagination->getOffset(), $pagination->getLimit());
		}
		else
			return $this->rawData;
	}
1030173
public function findPage()
    {
        $data['data'] = $this->findAll();
        $data['data_count'] = $this->conn()->selectCollection($this->table_name)->count();

        return $data;
    }
289511
private function getPreviousPageQueryCriteria() {
        $start = $this->getIndexCriteria()->getOffset() - $this->getIndexCriteria()->getLimit();
        if($start < 0) {
            $start = 0;
        }
        return array(
            'start' => $start,
            'count' => $this->getIndexCriteria()->getLimit()
        );
    }
142092
protected function getPages(): array
    {
        $pages = [];

        $pages['previous_page'] = $this->pagerfanta->hasPreviousPage() ?
            $this->generateUrl($this->pagerfanta->getPreviousPage()) :
            false;

        $pages['first_page'] = $this->startPage > 1 ? $this->generateUrl(1) : false;
        $pages['mobile_first_page'] = $this->pagerfanta->getCurrentPage() > 2 ? $this->generateUrl(1) : false;

        $pages['second_page'] = $this->startPage === 3 ? $this->generateUrl(2) : false;

        $pages['separator_before'] = $this->startPage > 3;

        $middlePages = [];
        for ($i = $this->startPage, $end = $this->endPage; $i <= $end; ++$i) {
            $middlePages[$i] = $this->generateUrl($i);
        }

        $pages['middle_pages'] = $middlePages;

        $pages['separator_after'] = $this->endPage < $this->pagerfanta->getNbPages() - 2;

        $pages['second_to_last_page'] = $this->endPage === $this->pagerfanta->getNbPages() - 2 ?
            $this->generateUrl($this->pagerfanta->getNbPages() - 1) :
            false;

        $pages['last_page'] = $this->pagerfanta->getNbPages() > $this->endPage ?
            $this->generateUrl($this->pagerfanta->getNbPages()) :
            false;

        $pages['mobile_last_page'] = $this->pagerfanta->getCurrentPage() < $this->pagerfanta->getNbPages() - 1 ?
            $this->generateUrl($this->pagerfanta->getNbPages()) :
            false;

        $pages['next_page'] = $this->pagerfanta->hasNextPage() ?
            $this->generateUrl($this->pagerfanta->getNextPage()) :
            false;

        return $pages;
    }