Automattic\WooCommerce\Admin\RemoteInboxNotifications\Transformers

ArrayColumn{}WC 1.0

Search array value by one of its key.

No Hooks.

Usage

$ArrayColumn = new ArrayColumn();
// 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

ArrayColumn{} code WC 8.3.0

class ArrayColumn implements TransformerInterface {
	/**
	 * Search array value by one of its key.
	 *
	 * @param mixed         $value a value to transform.
	 * @param stdClass|null $arguments required arguments 'key'.
	 * @param string|null   $default default value.
	 *
	 * @throws InvalidArgumentException Throws when the required argument 'key' is missing.
	 *
	 * @return mixed
	 */
	public function transform( $value, stdClass $arguments = null, $default = null ) {
		return array_column( $value, $arguments->key );
	}

	/**
	 * Validate Transformer arguments.
	 *
	 * @param stdClass|null $arguments arguments to validate.
	 *
	 * @return mixed
	 */
	public function validate( stdClass $arguments = null ) {
		if ( ! isset( $arguments->key ) ) {
			return false;
		}

		return true;
	}
}