WooCommerce Code Reference

Formatters
in package

Formatters class.

Allows formatter classes to be registered. Formatters are exposed to extensions via the ExtendSchema class.

Table of Contents

$formatters  : array<string|int, mixed>
Holds an array of formatter class instances.
__get()  : FormatterInterface
Get a new instance of a formatter class.
register()  : mixed
Register a formatter class for usage.

Properties

$formatters

Holds an array of formatter class instances.

private array<string|int, mixed> $formatters = []

Methods

__get()

Get a new instance of a formatter class.

public __get(string $name) : FormatterInterface
Parameters
$name : string

Name of the formatter.

Tags
throws
Exception

An Exception is thrown if a non-existing formatter is used and the user is admin.

Return values
FormatterInterfaceFormatter class instance.

register()

Register a formatter class for usage.

public register(string $name, string $class) : mixed
Parameters
$name : string

Name of the formatter.

$class : string

A formatter class name.

Return values
mixed