Automattic\WooCommerce\Admin\RemoteInboxNotifications\Transformers

ArrayFlatten{}WC 1.0

Flatten nested array.

No Hooks.

Usage

$ArrayFlatten = new ArrayFlatten();
// use class methods

Methods

  1. public transform( $value, stdClass $arguments = null, $default = null )
  2. public validate( stdClass $arguments = null )

Notes

  • Package: Automattic\WooCommerce\Admin\RemoteInboxNotifications\Transformers

Code of ArrayFlatten{} WC 6.6.1

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 default value.
	 *
	 * @return mixed|null
	 */
	public function transform( $value, stdClass $arguments = null, $default = null ) {
		$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;
	}
}