[ Index ]

PHP Cross Reference of phpBB-3.3.3-deutsch

title

Body

[close]

/vendor/s9e/text-formatter/src/Configurator/Collections/ -> Collection.php (source)

   1  <?php
   2  
   3  /**
   4  * @package   s9e\TextFormatter
   5  * @copyright Copyright (c) 2010-2020 The s9e authors
   6  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
   7  */
   8  namespace s9e\TextFormatter\Configurator\Collections;
   9  
  10  use Countable;
  11  use Iterator;
  12  use s9e\TextFormatter\Configurator\ConfigProvider;
  13  use s9e\TextFormatter\Configurator\Helpers\ConfigHelper;
  14  
  15  class Collection implements ConfigProvider, Countable, Iterator
  16  {
  17      /**
  18      * @var array Items that this collection holds
  19      */
  20      protected $items = [];
  21  
  22      /**
  23      * Empty this collection
  24      */
  25  	public function clear()
  26      {
  27          $this->items = [];
  28      }
  29  
  30      /**
  31      * @return mixed
  32      */
  33  	public function asConfig()
  34      {
  35          return ConfigHelper::toArray($this->items, true);
  36      }
  37  
  38      //==========================================================================
  39      // Countable stuff
  40      //==========================================================================
  41  
  42      /**
  43      * @return integer
  44      */
  45  	public function count()
  46      {
  47          return count($this->items);
  48      }
  49  
  50      //==========================================================================
  51      // Iterator stuff
  52      //==========================================================================
  53  
  54      /**
  55      * @return mixed
  56      */
  57  	public function current()
  58      {
  59          return current($this->items);
  60      }
  61  
  62      /**
  63      * @return integer|string
  64      */
  65  	public function key()
  66      {
  67          return key($this->items);
  68      }
  69  
  70      /**
  71      * @return mixed
  72      */
  73  	public function next()
  74      {
  75          return next($this->items);
  76      }
  77  
  78      /**
  79      * @return void
  80      */
  81  	public function rewind()
  82      {
  83          reset($this->items);
  84      }
  85  
  86      /**
  87      * @return bool
  88      */
  89  	public function valid()
  90      {
  91          return (key($this->items) !== null);
  92      }
  93  }


Generated: Sun Feb 14 20:08:31 2021 Cross-referenced by PHPXref 0.7.1