[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/restful/src/RESTful/ -> ItemizationIterator.php (source)

   1  <?php
   2  
   3  namespace RESTful;
   4  
   5  class ItemizationIterator implements \Iterator
   6  {
   7      protected $_page,
   8          $_offset = 0;
   9  
  10      public function __construct($resource, $uri, $data = null)
  11      {
  12          $this->_page = new Page($resource, $uri, $data);
  13      }
  14  
  15      // Iterator
  16      public function current()
  17      {
  18          return $this->_page->items[$this->_offset];
  19      }
  20  
  21      public function key()
  22      {
  23          return $this->_page->offset + $this->_offset;
  24      }
  25  
  26      public function next()
  27      {
  28          $this->_offset += 1;
  29          if ($this->_offset >= count($this->_page->items)) {
  30              $this->_offset = 0;
  31              $this->_page = $this->_page->next();
  32          }
  33      }
  34  
  35      public function rewind()
  36      {
  37          $this->_page = $this->_page->first();
  38          $this->_offset = 0;
  39      }
  40  
  41      public function valid()
  42      {
  43          return ($this->_page != null && $this->_offset < count($this->_page->items));
  44      }
  45  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1