FormatterHelper
extends Helper
in package
The Formatter class provides helpers to format messages.
Tags
Table of Contents
- $helperSet : mixed
- 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() : mixed
- {@inheritdoc}
- length() : int
- Returns the length of a string, using mb_strlen if it is available.
- 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.
- width() : int
- Returns the width of a string, using mb_strwidth if it is available.
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
- $large : bool = false
Return values
string —The formatter message
formatMemory()
public
static formatMemory(int $memory) : mixed
Parameters
- $memory : int
Return values
mixed —formatSection()
Formats a message within a section.
public
formatSection(string $section, string $message[, string $style = 'info' ]) : string
Parameters
- $section : string
- $message : string
- $style : string = 'info'
Return values
string —The format section
formatTime()
public
static formatTime(mixed $secs) : mixed
Parameters
- $secs : mixed
Return values
mixed —getHelperSet()
Gets the helper set associated with this helper.
public
getHelperSet() : HelperSet
Return values
HelperSet —A HelperSet instance
getName()
{@inheritdoc}
public
getName() : mixed
Return values
mixed —length()
Returns the length of a string, using mb_strlen if it is available.
public
static length(string|null $string) : int
The length is related to how many bytes the string will use.
Parameters
- $string : string|null
Return values
int —removeDecoration()
public
static removeDecoration(OutputFormatterInterface $formatter, string|null $string) : mixed
Parameters
- $formatter : OutputFormatterInterface
- $string : string|null
Return values
mixed —setHelperSet()
Sets the helper set associated with this helper.
public
setHelperSet([HelperSet $helperSet = null ]) : mixed
Parameters
- $helperSet : HelperSet = null
Return values
mixed —strlen()
Returns the length of a string, using mb_strwidth if it is available.
public
static strlen(string|null $string) : int
Parameters
- $string : string|null
Tags
Return values
int —The length of the string
strlenWithoutDecoration()
public
static strlenWithoutDecoration(OutputFormatterInterface $formatter, string|null $string) : mixed
Parameters
- $formatter : OutputFormatterInterface
- $string : string|null
Tags
Return values
mixed —substr()
Returns the subset of a string, using mb_substr if it is available.
public
static substr(string|null $string, int $from[, int $length = null ]) : string
Parameters
- $string : string|null
- $from : int
- $length : int = null
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 = '...'
Return values
string —width()
Returns the width of a string, using mb_strwidth if it is available.
public
static width(string|null $string) : int
The width is how many characters positions the string will use.
Parameters
- $string : string|null