Requests_Utility_FilteredIterator

Iterator for arrays requiring filtered values.

Defined (1)

The class is defined in the following location(s).

/wp-includes/Requests/Utility/FilteredIterator.php  
  1. class Requests_Utility_FilteredIterator extends ArrayIterator { 
  2. /** 
  3. * Callback to run as a filter 
  4. * @var callable 
  5. */ 
  6. protected $callback; 
  7.  
  8. /** 
  9. * Create a new iterator 
  10. * @param array $data 
  11. * @param callable $callback Callback to be called on each value 
  12. */ 
  13. public function __construct($data, $callback) { 
  14. parent::__construct($data); 
  15.  
  16. $this->callback = $callback; 
  17.  
  18. /** 
  19. * Get the current item's value after filtering 
  20. * @return string 
  21. */ 
  22. public function current() { 
  23. $value = parent::current(); 
  24. $value = call_user_func($this->callback, $value); 
  25. return $value;