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.
- Full name: \Gibbon\Services\FormatResolver
Methods
- addFormatter — Add a callable as an available format during runtime. Useful for additional modules.
- getFormatter — Get the callable function or method for a format by name.
- using — Returns a callable function that can be used to format a bulk array of data.
- keyValue — Formats an array of data into key => value pairs by applying a format method to each returned value.
- __callStatic — Calls a format method by name, allowing pre-defined formatters to be used.
addFormatter
Add a callable as an available format during runtime. Useful for additional modules.
static FormatResolver::addFormatter( string $method, callable $callable )
- This method is static.
getFormatter
Get the callable function or method for a format by name.
static FormatResolver::getFormatter( string $method ): callable
- This method is static.
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.
- This method is static.
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
- This method is static.
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
- This method is static.
Return Value:
mixed