Apple News API PHP Client

Byline extends TextComponent
in package

FinalYes

Byline component for publication date and contributor credits.

The byline component is typically used to display publication information such as the date, author names, and other credits in a single line.

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

Table of Contents

Properties

$additions  : array<string|int, array<string, mixed>>|null
$anchor  : string|null
$animation  : array<string, mixed>|null
$behavior  : array<string, mixed>|null
$conditional  : array<string, mixed>|null
$format  : string|null
$hidden  : bool
$identifier  : string|null
$inlineTextStyles  : array<string|int, array<string, mixed>>|null
$layout  : string|null
$style  : string|null
$text  : string
$textStyle  : string|null

Methods

__construct()  : mixed
getRole()  : string
Get the role name for the component (e.g., 'body', 'photo', 'heading1').
getStyle()  : string|null
Get the component style name.
getTextStyle()  : string|null
Get the text style name.
jsonSerialize()  : array<string, mixed>
Implementation of JsonSerializable.
setAdditions()  : static
Set additions (link ranges) for the text component.
setAnchor()  : static
Set the anchor configuration.
setAnimation()  : static
Set component animation using an array.
setAnimationObject()  : static
Set the component animation using a typed Animation object.
setBehavior()  : static
Set the component behavior using an array.
setBehaviorObject()  : static
Set the component behavior using a typed Behavior object.
setConditional()  : static
Set conditional properties for the component.
setFormat()  : static
Set the format of the text content ('html' or 'markdown').
setHidden()  : static
Set whether the component is hidden.
setIdentifier()  : static
Set a unique identifier for this component.
setInlineTextStyles()  : static
Define specific styles for ranges of text within this component.
setLayout()  : static
Set the layout name or inline layout.
setStyle()  : static
Set the style name.
setTextStyle()  : static
Set the text style name.
getBaseProperties()  : array<string, mixed>
Get the base properties common to all components for JSON serialization.

Properties

$additions

protected array<string|int, array<string, mixed>>|null $additions = null

Additions (links) applied to text ranges.

$anchor

protected string|null $anchor = null

Anchor configuration for pinning components.

$animation

protected array<string, mixed>|null $animation = null

Animation settings for the component.

$behavior

protected array<string, mixed>|null $behavior = null

Behavior settings (e.g., Parallax).

$conditional

protected array<string, mixed>|null $conditional = null

Conditional properties based on orientation/device.

$format

protected string|null $format = null

The text format (none, html, markdown).

$hidden

protected bool $hidden = false

Whether the component is hidden by default.

$identifier

protected string|null $identifier = null

A unique identifier for this component instance.

$inlineTextStyles

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

Inline style overrides.

$layout

protected string|null $layout = null

Reference to a named layout defined in Article.

$style

protected string|null $style = null

Reference to a named style defined in Article.

$textStyle

protected string|null $textStyle = null

Reference to a named text style.

Methods

__construct()

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

The raw text content.

getRole()

Get the role name for the component (e.g., 'body', 'photo', 'heading1').

public getRole() : string
Return values
string

getStyle()

Get the component style name.

public getStyle() : string|null
Return values
string|null —

The name set with setStyle(), or null.

getTextStyle()

Get the text style name.

public getTextStyle() : string|null
Return values
string|null —

The name set with setTextStyle(), or null.

jsonSerialize()

Implementation of JsonSerializable.

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

setAdditions()

Set additions (link ranges) for the text component.

public setAdditions(array<string|int, array<string, mixed>> $additions) : static

Additions allow you to apply links to specific ranges of text. Note: Additions are not supported when format is 'html' or 'markdown'.

Parameters
$additions : array<string|int, array<string, mixed>>

Array of addition objects with rangeStart, rangeLength, and link.

Tags
see
https://developer.apple.com/documentation/applenewsformat/addition
Return values
static

setAnchor()

Set the anchor configuration.

public setAnchor(string $anchor) : static
Parameters
$anchor : string

The anchor configuration.

Return values
static

setAnimationObject()

Set the component animation using a typed Animation object.

public setAnimationObject(AnimationInterface $animation) : static

This method provides type-safe animation configuration:

$photo->setAnimationObject(FadeInAnimation::fromTransparent());
$body->setAnimationObject(MoveInAnimation::fromLeft());
Parameters
$animation : AnimationInterface

The animation object.

Return values
static

setBehaviorObject()

Set the component behavior using a typed Behavior object.

public setBehaviorObject(BehaviorInterface $behavior) : static

This method provides type-safe behavior configuration:

$photo->setBehaviorObject(Parallax::withFactor(0.8));
$photo->setBehaviorObject(new Springy());
Parameters
$behavior : BehaviorInterface

The behavior object.

Return values
static

setFormat()

Set the format of the text content ('html' or 'markdown').

public setFormat(string $format) : static
Parameters
$format : string
Return values
static

setHidden()

Set whether the component is hidden.

public setHidden(bool $hidden) : static
Parameters
$hidden : bool

Whether to hide the component.

Return values
static

setIdentifier()

Set a unique identifier for this component.

public setIdentifier(string $identifier) : static
Parameters
$identifier : string

The unique identifier.

Return values
static

setInlineTextStyles()

Define specific styles for ranges of text within this component.

public setInlineTextStyles(array<string|int, array<string, mixed>> $styles) : static
Parameters
$styles : array<string|int, array<string, mixed>>
Return values
static

setLayout()

Set the layout name or inline layout.

public setLayout(string $layout) : static
Parameters
$layout : string

Reference to a name in componentLayouts.

Return values
static

setStyle()

Set the style name.

public setStyle(string $style) : static
Parameters
$style : string

Reference to a name in componentStyles.

Return values
static

setTextStyle()

Set the text style name.

public setTextStyle(string $textStyle) : static
Parameters
$textStyle : string
Return values
static

getBaseProperties()

Get the base properties common to all components for JSON serialization.

protected getBaseProperties() : array<string, mixed>
Return values
array<string, mixed>

        
On this page

Search results