[ Index ]

PHP Cross Reference of phpBB-3.3.14-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-2022 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(): int
  46      {
  47          return count($this->items);
  48      }
  49  
  50      //==========================================================================
  51      // Iterator stuff
  52      //==========================================================================
  53  
  54      /**
  55      * @return mixed
  56      */
  57      #[\ReturnTypeWillChange]
  58  	public function current()
  59      {
  60          return current($this->items);
  61      }
  62  
  63      /**
  64      * @return integer|string
  65      */
  66      #[\ReturnTypeWillChange]
  67  	public function key()
  68      {
  69          return key($this->items);
  70      }
  71  
  72      /**
  73      * @return mixed
  74      */
  75      #[\ReturnTypeWillChange]
  76  	public function next()
  77      {
  78          return next($this->items);
  79      }
  80  
  81      /**
  82      * @return void
  83      */
  84  	public function rewind(): void
  85      {
  86          reset($this->items);
  87      }
  88  
  89      /**
  90      * @return bool
  91      */
  92  	public function valid(): bool
  93      {
  94          return (key($this->items) !== null);
  95      }
  96  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1