[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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          $value = call_user_func($this->callback, $value);
  43          return $value;
  44      }
  45  
  46      /**
  47       * @inheritdoc
  48       */
  49  	public function unserialize( $serialized ) {
  50      }
  51  
  52      /**
  53       * @inheritdoc
  54       */
  55  	public function __unserialize( $serialized ) { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.MethodDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__unserializeFound
  56      }
  57  
  58  	public function __wakeup() { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.MethodDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__wakeupFound
  59          unset( $this->callback );
  60      }
  61  }


Generated : Sun Jan 24 08:20:01 2021 Cross-referenced by PHPXref