Apple News API PHP Client

CaptionDescriptor
in package
implements JsonSerializable

FinalYes

Caption descriptor for media components.

Used for Photo, Gallery, Mosaic, and other media components to provide rich captions with formatting and interactivity.

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

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 CaptionDescriptor.
addAddition()  : $this
Add an addition.
addInlineTextStyle()  : $this
Add an inline text style.
html()  : self
Create an HTML caption.
jsonSerialize()  : array<string, mixed>
{@inheritdoc}
markdown()  : self
Create a Markdown caption.
plain()  : self
Create a plain text caption.
setAdditions()  : $this
Set additions.
setFormat()  : $this
Set the text format.
setInlineTextStyles()  : $this
Set inline text styles.
setTextStyle()  : $this
Set the text style reference.

Constants

Properties

$inlineTextStyles

Inline text styles.

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

Methods

__construct()

Create a new CaptionDescriptor.

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

The caption text.

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 an HTML caption.

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

The HTML caption.

Return values
self

A new instance.

jsonSerialize()

{@inheritdoc}

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

markdown()

Create a Markdown caption.

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

The Markdown caption.

Return values
self

A new instance.

plain()

Create a plain text caption.

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

The caption text.

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