Apple News API PHP Client

FormattedText
in package
implements JsonSerializable

FinalYes

Formatted text with styling support.

Used for complex text content that requires inline styling, additions, or specific formatting.

Tags
see
https://developer.apple.com/documentation/apple_news/formattedtext

Table of Contents

Interfaces

JsonSerializable

Constants

FORMAT_HTML  = 'html'
Valid format types.
FORMAT_MARKDOWN  = 'markdown'
FORMAT_NONE  = 'none'

Properties

$additions  : array<int, AdditionInterface>|null
Additions (links, etc.).
$format  : string|null
The text format.
$inlineTextStyles  : array<int, array<string, mixed>>|null
Inline text styles.
$text  : string
$textStyle  : string|null
The text style reference.

Methods

__construct()  : mixed
Create a new FormattedText.
addAddition()  : $this
Add an addition.
addInlineTextStyle()  : $this
Add an inline text style.
html()  : self
Create formatted text from HTML.
jsonSerialize()  : array<string, mixed>
{@inheritdoc}
markdown()  : self
Create formatted text from Markdown.
plain()  : self
Create formatted text from plain text.
setAdditions()  : $this
Set additions.
setFormat()  : $this
Set the text format.
setInlineTextStyles()  : $this
Set inline text styles.
setTextStyle()  : $this
Set the text style reference.

Constants

FORMAT_HTML

Valid format types.

public mixed FORMAT_HTML = 'html'

Properties

$inlineTextStyles

Inline text styles.

private array<int, array<string, mixed>>|null $inlineTextStyles = null

$textStyle

The text style reference.

private string|null $textStyle = null

Methods

__construct()

Create a new FormattedText.

public __construct(string $text) : mixed
Parameters
$text : string

The text content.

addInlineTextStyle()

Add an inline text style.

public addInlineTextStyle(int $rangeStart, int $rangeLength, string|array<string, mixed> $textStyle) : $this
Parameters
$rangeStart : int

The starting position.

$rangeLength : int

The length.

$textStyle : string|array<string, mixed>

The text style name or inline definition.

Return values
$this

html()

Create formatted text from HTML.

public static html(string $html) : self
Parameters
$html : string

The HTML content.

Return values
self

A new instance.

jsonSerialize()

{@inheritdoc}

public jsonSerialize() : array<string, mixed>
Return values
array<string, mixed>

markdown()

Create formatted text from Markdown.

public static markdown(string $markdown) : self
Parameters
$markdown : string

The Markdown content.

Return values
self

A new instance.

plain()

Create formatted text from plain text.

public static plain(string $text) : self
Parameters
$text : string

The text content.

Return values
self

A new instance.

setFormat()

Set the text format.

public setFormat(string $format) : $this
Parameters
$format : string

One of 'html', 'markdown', 'none'.

Return values
$this

setInlineTextStyles()

Set inline text styles.

public setInlineTextStyles(array<int, array<string, mixed>> $styles) : $this
Parameters
$styles : array<int, array<string, mixed>>

The inline styles.

Return values
$this

setTextStyle()

Set the text style reference.

public setTextStyle(string $textStyle) : $this
Parameters
$textStyle : string

The text style name.

Return values
$this

        
On this page

Search results