WP_CLI\Iterators
Transform{}
Applies one or more callbacks to an item before returning it.
No Hooks.
Usage
$Transform = new Transform(); // use class methods
Methods
- public add_transform( $fn )
- public current()
Transform{} Transform{} code WP-CLI 2.8.0-alpha
class Transform extends IteratorIterator { private $transformers = []; public function add_transform( $fn ) { $this->transformers[] = $fn; } public function current() { $value = parent::current(); foreach ( $this->transformers as $fn ) { $value = call_user_func( $fn, $value ); } return $value; } }