[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/Requests/Utility/ -> FilteredIterator.php (source)

   1  <?php
   2  /**
   3   * Iterator for arrays requiring filtered values
   4   *
   5   * @package Requests
   6   * @subpackage Utilities
   7   */
   8  
   9  /**
  10   * Iterator for arrays requiring filtered values
  11   *
  12   * @package Requests
  13   * @subpackage Utilities
  14   */
  15  class Requests_Utility_FilteredIterator extends ArrayIterator {
  16      /**
  17       * Callback to run as a filter
  18       *
  19       * @var callable
  20       */
  21      protected $callback;
  22  
  23      /**
  24       * Create a new iterator
  25       *
  26       * @param array $data
  27       * @param callable $callback Callback to be called on each value
  28       */
  29  	public function __construct($data, $callback) {
  30          parent::__construct($data);
  31  
  32          $this->callback = $callback;
  33      }
  34  
  35      /**
  36       * Get the current item's value after filtering
  37       *
  38       * @return string
  39       */
  40  	public function current() {
  41          $value = parent::current();
  42  
  43          if (is_callable($this->callback)) {
  44              $value = call_user_func($this->callback, $value);
  45          }
  46  
  47          return $value;
  48      }
  49  
  50      /**
  51       * @inheritdoc
  52       */
  53  	public function unserialize($serialized) {}
  54  
  55      /**
  56       * @inheritdoc
  57       *
  58       * @phpcs:disable PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.MethodDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__unserializeFound
  59       */
  60  	public function __unserialize($serialized) {}
  61  
  62  	public function __wakeup() {
  63          unset($this->callback);
  64      }
  65  }


Generated: Thu Dec 15 01:00:02 2022 Cross-referenced by PHPXref 0.7.1