FormatResolver

FormatResolver

The resolver allows modules to add their own formatters, which can be accessed with Format::newMethod I can also return a formatter as a closure with the using() method, which can be provided to classes such as the DataTable that loop over and format array data.

Methods

addFormatter

Add a callable as an available format during runtime. Useful for additional modules.

static FormatResolver::addFormatter( string $method, callable $callable )

getFormatter

Get the callable function or method for a format by name.

static FormatResolver::getFormatter( string $method ): callable

Return Value: callable


using

Returns a callable function that can be used to format a bulk array of data.

static FormatResolver::using( string $method, array $param = null ): callable

The callable returned takes a single array of data and returns the formatted string.

Return Value: callable


keyValue

Formats an array of data into key => value pairs by applying a format method to each returned value.

static FormatResolver::keyValue( array $data, string $key, string $method, array $param = null ): array

Return Value: array


__callStatic

Calls a format method by name, allowing pre-defined formatters to be used.

static FormatResolver::__callStatic( string $method, array $arguments = array() ): mixed

Return Value: mixed