StyledText
final readonly class \
A line of output as text segments with an optional console style each.
Internal
Table of Contents
Constants
- STYLE_DIM : string = 'inspect_dim'
- STYLE_ELLIPSIS : string = 'inspect_ellipsis'
- STYLE_KEY : string = 'inspect_key'
- STYLE_MARKER : string = 'inspect_marker'
- STYLE_NULL : string = 'inspect_null'
- STYLE_NUMBER : string = 'inspect_number'
- STYLE_SECRET : string = 'inspect_secret'
- STYLE_STRING : string = 'inspect_string'
Properties
- $segments : array
Methods
- __construct() : mixed
- append() : self
- concat() : self
- format() : string
- plain() : string
- truncate() : self
- Cuts the text so that it fits into $maxWidth including a trailing ellipsis.
- width() : int
- withStyle() : self
Constants
STYLE_DIM
public
string
STYLE_DIM
= 'inspect_dim'
STYLE_ELLIPSIS
public
string
STYLE_ELLIPSIS
= 'inspect_ellipsis'
STYLE_KEY
public
string
STYLE_KEY
= 'inspect_key'
STYLE_MARKER
public
string
STYLE_MARKER
= 'inspect_marker'
STYLE_NULL
public
string
STYLE_NULL
= 'inspect_null'
STYLE_NUMBER
public
string
STYLE_NUMBER
= 'inspect_number'
STYLE_SECRET
public
string
STYLE_SECRET
= 'inspect_secret'
STYLE_STRING
public
string
STYLE_STRING
= 'inspect_string'
Properties
$segments
public
array
$segments
= []
Methods
__construct()
public
__construct([array<int, array{string, ?string}> $segments = [] ]) : mixed
Parameters
- $segments : array<int, array{string, ?string}> = []
append()
public
append(string $text[, string|null $style = null ]) : self
Parameters
- $text : string
- $style : string|null = null
Return values
selfconcat()
public
concat(self $other) : self
Parameters
- $other : self
Return values
selfformat()
public
format() : string
Return values
stringplain()
public
plain() : string
Return values
stringtruncate()
Cuts the text so that it fits into $maxWidth including a trailing ellipsis.
public
truncate(int $maxWidth) : self
Parameters
- $maxWidth : int
Return values
selfwidth()
public
width() : int
Return values
intwithStyle()
public
withStyle(string $from, string $to) : self
Parameters
- $from : string
- $to : string