PHP Class PhpBench\Formatter\Formatter

显示文件 Open project: dantleech/phpbench Class Usage Examples

Public Methods

Method Description
__construct ( FormatRegistry $registry, ClassLoader $loader = null )
applyClasses ( array $classNames, string $value, array $params = [] ) : string Apply the a set of classes (indicated by $classNames) to the given value.
classesFromFile ( string $filename ) Register classes from a given JSON encoded class definition file.
registerClass ( string $name, array $formatDefinitions ) Register a single class with its format definitions.
registerClasses ( array $classDefinitions ) Register class definitions.

Private Methods

Method Description
substituteTokens ( array $formatConfig, $params )

Method Details

__construct() public method

public __construct ( FormatRegistry $registry, ClassLoader $loader = null )
$registry FormatRegistry
$loader ClassLoader

applyClasses() public method

Parameters can be given: parameters are used to replcae any tokens used in the format options; this is required when options should be overridden on a per-subject basis.
public applyClasses ( array $classNames, string $value, array $params = [] ) : string
$classNames array
$value string
$params array
return string

classesFromFile() public method

Register classes from a given JSON encoded class definition file.
public classesFromFile ( string $filename )
$filename string

registerClass() public method

Each format definition should be of the form: [ $formatterName, { $options1 => $value 1 } ] i.e. a 2 element tuple with a scalar (the name of the formatter) and an associative array of formatter options.
public registerClass ( string $name, array $formatDefinitions )
$name string
$formatDefinitions array

registerClasses() public method

Class definitions have the form $className => (array) $formatDefinitions
public registerClasses ( array $classDefinitions )
$classDefinitions array