original_string: protected function getCurrentPageNumber($query)
      {
          $currentPageNumber = $this->currentPageNumber;
  
          if (!$currentPageNumber && empty($this->searchTerm)) {
              // Restore the last visited page from the session if available.
              $currentPageNumber = $this->getSession('lastVisitedPage');
          }
  
          $currentPageNumber = intval($currentPageNumber);
  
          if ($currentPageNumber > 1) {
              $count = $query->count();
  
              // If the current page number is higher than the amount of available pages, go to the last available page
              if ($count <= (($currentPageNumber - 1) * $this->recordsPerPage)) {
                  $currentPageNumber = ceil($count / $this->recordsPerPage);
              }
          }
  
          return $currentPageNumber;
      }
code: protected function getCurrentPageNumber($query)
      {
          $currentPageNumber = $this->currentPageNumber;
  
          if (!$currentPageNumber && empty($this->searchTerm)) {
              // Restore the last visited page from the session if available.
              $currentPageNumber = $this->getSession('lastVisitedPage');
          }
  
          $currentPageNumber = intval($currentPageNumber);
  
          if ($currentPageNumber > 1) {
              $count = $query->count();
  
              // If the current page number is higher than the amount of available pages, go to the last available page
              if ($count <= (($currentPageNumber - 1) * $this->recordsPerPage)) {
                  $currentPageNumber = ceil($count / $this->recordsPerPage);
              }
          }
  
          return $currentPageNumber;
      }
code_tokens: protected function getCurrentPageNumber ( $ query ) { $ currentPageNumber = $ this -> currentPageNumber ; if ( ! $ currentPageNumber && empty ( $ this -> searchTerm ) ) { // Restore the last visited page from the session if available. $ currentPageNumber = $ this -> getSession ( 'lastVisitedPage' ) ; } $ currentPageNumber = intval ( $ currentPageNumber ) ; if ( $ currentPageNumber > 1 ) { $ count = $ query -> count ( ) ; // If the current page number is higher than the amount of available pages, go to the last available page if ( $ count <= ( ( $ currentPageNumber - 1 ) * $ this -> recordsPerPage ) ) { $ currentPageNumber = ceil ( $ count / $ this -> recordsPerPage ) ; } } return $ currentPageNumber ; }
docstring: Returns the current page number for the list.
  
  This will override the current page number provided by the user if it is past the last page of available records.
  
  @param object $query
  @return int
docstring_tokens: Returns the current page number for the list .