Library
Class

Library\Reporter\Reporter

class Reporter

Constants

OUTPUT_BY_LINE

Set the reporter to return each output rendering

OUTPUT_APPEND

Set the reporter to append each output rendering to a global output

Properties

static array $default_tag_types
static array $default_masks

Methods

__construct(null|string $adapter_type = 'html', int $flag = self::OUTPUT_BY_LINE)

Construction of a new Reporter object

Reporter reset(bool $hard = false)

Reset all object properties to default or empty values

string __toString()

Returns the object global output

Reporter setFlag(int $flag)

Set the reporter flag

int getFlag()

Get the reporter flag

Reporter setAdapterType(string $type)

Set the adapter type to use

object getAdapterType()

Get the current adapter name

Reporter setAdapter(AbstractAdapter $adapter)

Set the adapter

object getAdapter()

Get the current adapter

Reporter setOutput(string $output)

Set some content

string getOutput()

Get the processed content

string|Reporter render(string $content, string $tag_type = 'default', string|array $args = null)

Render a content with a specific tag mask

void write(string $content, string $tag_type = 'default', string|array $args = null)

Display on screen a content with a specific tag mask

string|Reporter renderMulti(string $content, string $tag_type = 'default', array $multi = array(), string|array $args = null, string $placeholder_mask = '@%s@')

Render a content with a specific tag mask and some placeholders

Details

at line 118
public __construct(null|string $adapter_type = 'html', int $flag = self::OUTPUT_BY_LINE)

Construction of a new Reporter object

Parameters

null|string $adapter_type The adapter type name
int $flag

at line 130
public Reporter reset(bool $hard = false)

Reset all object properties to default or empty values

Parameters

bool $hard Reset all object properties (adapter included)

Return Value

Reporter $this for method chaining

at line 145
public string __toString()

Returns the object global output

Return Value

string

at line 160
public Reporter setFlag(int $flag)

Set the reporter flag

Parameters

int $flag The flag to set

Return Value

Reporter Returns $this for method chaining

at line 171
public int getFlag()

Get the reporter flag

Return Value

int

at line 183
public Reporter setAdapterType(string $type)

Set the adapter type to use

Parameters

string $type The type name

Return Value

Reporter $this for method chaining

Exceptions

Throws a RuntimeException if the adapter doesn't exist

at line 201
public object getAdapterType()

Get the current adapter name

Return Value

object

at line 213
public Reporter setAdapter(AbstractAdapter $adapter)

Set the adapter

Parameters

AbstractAdapter $adapter The instance of a ReporterAdapter

Return Value

Reporter

Exceptions

LogicException

at line 232
public object getAdapter()

Get the current adapter

Return Value

object

at line 243
public Reporter setOutput(string $output)

Set some content

Parameters

string $output The content string

Return Value

Reporter Returns $this for method chaining

at line 258
public string getOutput()

Get the processed content

Return Value

string The content string

at line 277
public string|Reporter render(string $content, string $tag_type = 'default', string|array $args = null)

Render a content with a specific tag mask

Parameters

string $content The content string to use
string $tag_type The type of tag mask to use
string|array $args An array of arguments to pass to the mask (or a single string that will be taken as the first array item)

Return Value

string|Reporter Returns the line of output if the object flag is set on OUTPUT_BY_LINE, or $this if the flag is set on OUTPUT_APPEND

at line 299
public void write(string $content, string $tag_type = 'default', string|array $args = null)

Display on screen a content with a specific tag mask

Parameters

string $content The content string to use
string $tag_type The type of tag mask to use
string|array $args An array of arguments to pass to the mask (or a single string that will be taken as the first array item)

Return Value

void

at line 333
public string|Reporter renderMulti(string $content, string $tag_type = 'default', array $multi = array(), string|array $args = null, string $placeholder_mask = '@%s@')

Render a content with a specific tag mask and some placeholders

This is quite the same as the render() method but in this case, the $content string may contains some placeholders like @name@ that will be replaced in the result by the name item of the $multi array argument after rendering it by the render() method.

For instance:

$str = $obj->renderMulti( 'my string with @name@ placeholder', 'default', array(
    'name' => array( 'a specific string as' , 'strong' )
));

will return:

"<p>my string with <strong>a specific string as</strong> placeholder</p>"

Parameters

string $content The content string to use
string $tag_type The type of tag mask to use
array $multi The array of imbricated elements for content replacements
string|array $args An array of arguments to pass to the mask (or a single string that will be taken as the first array item)
string $placeholder_mask The mask used to build placeholders names in $content

Return Value

string|Reporter Returns the line of output if the object flag is set on OUTPUT_BY_LINE, or $this if the flag is set on OUTPUT_APPEND