Automattic\WooCommerce\Api\Infrastructure

MetadataController::get_entry_typeprivate staticWC 1.0

The MetadataEntry output type, lazily built and cached.

Method of the class: MetadataController{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = MetadataController::get_entry_type(): ObjectType;

MetadataController::get_entry_type() code WC 10.9.1

private static function get_entry_type(): ObjectType {
	if ( null === self::$entry_type ) {
		self::$entry_type = new ObjectType(
			array(
				'name'        => 'MetadataEntry',
				'description' => __( 'One metadata entry: a `name` plus a scalar `value`.', 'woocommerce' ),
				'fields'      => fn() => array(
					'name'  => array(
						'type'        => Type::nonNull( Type::string() ),
						'description' => __( 'Identifier of the entry (e.g. `internal`, `beta`).', 'woocommerce' ),
					),
					'value' => array(
						// Nullable: `MetadataValue` itself permits a null payload (e.g.
						// `#[Metadata( 'deprecated_reason', null )]`), so the wrapping
						// must allow it through.
						'type'        => self::get_value_scalar(),
						'description' => __( 'Scalar payload associated with the entry. Null when the metadata entry carries a null value.', 'woocommerce' ),
					),
				),
			)
		);
	}
	return self::$entry_type;
}