Source for file PaginatedResult.php

Documentation is available at PaginatedResult.php

  1. <?
  2.  
  3. /** Stores information of a result that spans across multiple pages.
  4.  *
  5.  * @package    php-lastfm-api
  6.  * @author  Felix Bruns <felixbruns@web.de>
  7.  * @version    1.0
  8.  */
  9. class PaginatedResult {
  10.     /** The number of total results.
  11.      *
  12.      * @var integer 
  13.      * @access    private
  14.      */
  15.     private $totalResults;
  16.  
  17.     /** The index of the first element in this result.
  18.      *
  19.      * @var integer 
  20.      * @access    private
  21.      */
  22.     private $startIndex;
  23.  
  24.     /** The number of items per page.
  25.      *
  26.      * @var integer 
  27.      * @access    private
  28.      */
  29.     private $itemsPerPage;
  30.  
  31.     /** An array of results.
  32.      *
  33.      * @var array 
  34.      * @access    private
  35.      */
  36.     private $results;
  37.  
  38.     /** Create a PaginatedResult object.
  39.      *
  40.      * @param integer    $totalResults    Number of total results.
  41.      * @param integer    $startIndex        Index of the first result element.
  42.      * @param integer    $itemsPerPage    Number of items per page.
  43.      * @param array        $results        An array of results.
  44.      *
  45.      * @access    public
  46.      */
  47.     public function __construct($totalResults$startIndex$itemsPerPage$results){
  48.         $this->totalResults $totalResults;
  49.         $this->startIndex   $startIndex;
  50.         $this->itemsPerPage $itemsPerPage;
  51.         $this->results      $results;
  52.     }
  53.  
  54.     /** Returns the number of total results.
  55.      *
  56.      * @return    integer    Number of total results.
  57.      * @access    public
  58.      */
  59.     public function getTotalResults(){
  60.         return $this->totalResults;
  61.     }
  62.  
  63.     /** Returns the index of the first result element.
  64.      *
  65.      * @return    integer    Index of the first element.
  66.      * @access    public
  67.      */
  68.     public function getStartIndex(){
  69.         return $this->startIndex;
  70.     }
  71.  
  72.     /** Returns the current page.
  73.      *
  74.      * @return    integer    Current page number.
  75.      * @access    public
  76.      */
  77.     public function getCurrentPage(){
  78.         return ($this->startIndex $this->itemsPerPage1;
  79.     }
  80.  
  81.     /** Returns the number of items per page.
  82.      *
  83.      * @return    integer    Number of items per page.
  84.      * @access    public
  85.      */
  86.     public function getItemsPerPage(){
  87.         return $this->itemsPerPage;
  88.     }
  89.  
  90.     /** Returns the number total pages.
  91.      *
  92.      * @return    integer Total pages.
  93.      * @access    public
  94.      */
  95.     public function getPages(){
  96.         return intval(round($this->totalResults $this->itemsPerPage));
  97.     }
  98.  
  99.     /** Returns the array of results.
  100.      *
  101.      * @return    array    An array of result elements.
  102.      * @access    public
  103.      */
  104.     public function getResults(){
  105.         return $this->results;
  106.     }
  107. }
  108.  
  109. ?>

Documentation generated on Mon, 22 Dec 2008 16:57:40 +0100 by phpDocumentor 1.4.1