[ 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          $value = call_user_func($this->callback, $value);
  43          return $value;
  44      }
  45  }


Generated: Tue Jan 28 01:00:03 2020 Cross-referenced by PHPXref 0.7.1