Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\Transformers
ArrayFlatten{}└─ TransformerInterface
Flatten nested array.
No Hooks.
Usage
$ArrayFlatten = new ArrayFlatten(); // use class methods
Methods
- public transform( $value, ?stdClass $arguments = null, $default_value = array() )
- public validate( ?stdClass $arguments = null )
Notes
- Package: Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\Transformers
ArrayFlatten{} ArrayFlatten{} code WC 10.7.0
class ArrayFlatten implements TransformerInterface {
/**
* Search a given value in the array.
*
* @param mixed $value a value to transform.
* @param stdClass|null $arguments arguments.
* @param string|null $default_value default value.
*
* @return mixed|null
*/
public function transform( $value, ?stdClass $arguments = null, $default_value = array() ) {
if ( ! is_array( $value ) ) {
return $default_value;
}
$return = array();
array_walk_recursive(
$value,
function ( $item ) use ( &$return ) {
$return[] = $item;
}
);
return $return;
}
/**
* Validate Transformer arguments.
*
* @param stdClass|null $arguments arguments to validate.
*
* @return mixed
*/
public function validate( ?stdClass $arguments = null ) {
return true;
}
}