FormatterHelper
extends Helper
in package
The Formatter class provides helpers to format messages.
Tags
Table of Contents
Properties
- $helperSet : mixed
Methods
- formatBlock() : string
- Formats a message as a block of text.
- formatMemory() : mixed
- formatSection() : string
- Formats a message within a section.
- formatTime() : mixed
- getHelperSet() : HelperSet
- Gets the helper set associated with this helper.
- getName() : string
- Returns the canonical name of this helper.
- removeDecoration() : mixed
- setHelperSet() : mixed
- Sets the helper set associated with this helper.
- strlen() : int
- Returns the length of a string, using mb_strwidth if it is available.
- strlenWithoutDecoration() : mixed
- substr() : string
- Returns the subset of a string, using mb_substr if it is available.
- truncate() : string
- Truncates a message to the given length.
Properties
$helperSet
protected
mixed
$helperSet
= null
Methods
formatBlock()
Formats a message as a block of text.
public
formatBlock(string|array<string|int, mixed> $messages, string $style[, bool $large = false ]) : string
Parameters
- $messages : string|array<string|int, mixed>
-
The message to write in the block
- $style : string
-
The style to apply to the whole block
- $large : bool = false
-
Whether to return a large block
Return values
string —The formatter message
formatMemory()
public
static formatMemory(mixed $memory) : mixed
Parameters
- $memory : mixed
formatSection()
Formats a message within a section.
public
formatSection(string $section, string $message[, string $style = 'info' ]) : string
Parameters
- $section : string
-
The section name
- $message : string
-
The message
- $style : string = 'info'
-
The style to apply to the section
Return values
string —The format section
formatTime()
public
static formatTime(mixed $secs) : mixed
Parameters
- $secs : mixed
getHelperSet()
Gets the helper set associated with this helper.
public
getHelperSet() : HelperSet
Return values
HelperSet —A HelperSet instance
getName()
Returns the canonical name of this helper.
public
getName() : string
Return values
string —The canonical name
removeDecoration()
public
static removeDecoration(OutputFormatterInterface $formatter, mixed $string) : mixed
Parameters
- $formatter : OutputFormatterInterface
- $string : mixed
setHelperSet()
Sets the helper set associated with this helper.
public
setHelperSet([HelperSet $helperSet = null ]) : mixed
Parameters
- $helperSet : HelperSet = null
strlen()
Returns the length of a string, using mb_strwidth if it is available.
public
static strlen(string $string) : int
Parameters
- $string : string
-
The string to check its length
Return values
int —The length of the string
strlenWithoutDecoration()
public
static strlenWithoutDecoration(OutputFormatterInterface $formatter, mixed $string) : mixed
Parameters
- $formatter : OutputFormatterInterface
- $string : mixed
substr()
Returns the subset of a string, using mb_substr if it is available.
public
static substr(string $string, int $from[, int|null $length = null ]) : string
Parameters
- $string : string
-
String to subset
- $from : int
-
Start offset
- $length : int|null = null
-
Length to read
Return values
string —The string subset
truncate()
Truncates a message to the given length.
public
truncate(string $message, int $length[, string $suffix = '...' ]) : string
Parameters
- $message : string
- $length : int
- $suffix : string = '...'