InlineTextStyle
in package
implements
JsonSerializable
FinalYes
Inline text style for specific ranges within text.
Tags
Table of Contents
Interfaces
- JsonSerializable
Properties
- $rangeLength : int
- $rangeStart : int
- $textStyle : string|array<string, mixed>|null
- The text style (reference or inline definition).
Methods
- __construct() : mixed
- Create a new InlineTextStyle.
- bold() : self
- Create a bold style for a range.
- colored() : self
- Create a colored text style for a range.
- forRange() : self
- Create an inline style for a range.
- italic() : self
- Create an italic style for a range.
- jsonSerialize() : array<string, mixed>
- {@inheritdoc}
- withInlineStyle() : $this
- Set an inline text style definition.
- withStyle() : $this
- Set the text style reference.
Properties
$rangeLength read-only
private
int
$rangeLength
$rangeStart read-only
private
int
$rangeStart
$textStyle
The text style (reference or inline definition).
private
string|array<string, mixed>|null
$textStyle
= null
Methods
__construct()
Create a new InlineTextStyle.
public
__construct(int $rangeStart, int $rangeLength) : mixed
Parameters
- $rangeStart : int
-
The starting position.
- $rangeLength : int
-
The length of the range.
bold()
Create a bold style for a range.
public
static bold(int $start, int $length) : self
Parameters
- $start : int
-
The starting position.
- $length : int
-
The length.
Return values
self —A new instance.
colored()
Create a colored text style for a range.
public
static colored(int $start, int $length, string $color) : self
Parameters
- $start : int
-
The starting position.
- $length : int
-
The length.
- $color : string
-
The text color.
Return values
self —A new instance.
forRange()
Create an inline style for a range.
public
static forRange(int $start, int $length) : self
Parameters
- $start : int
-
The starting position.
- $length : int
-
The length.
Return values
self —A new instance.
italic()
Create an italic style for a range.
public
static italic(int $start, int $length) : self
Parameters
- $start : int
-
The starting position.
- $length : int
-
The length.
Return values
self —A new instance.
jsonSerialize()
{@inheritdoc}
public
jsonSerialize() : array<string, mixed>
Return values
array<string, mixed>withInlineStyle()
Set an inline text style definition.
public
withInlineStyle(array<string, mixed> $style) : $this
Parameters
- $style : array<string, mixed>
-
The style definition.
Return values
$thiswithStyle()
Set the text style reference.
public
withStyle(string $styleName) : $this
Parameters
- $styleName : string
-
The text style name.