Apple News API PHP Client

ConditionalTextStyle
in package
implements ConditionalInterface

Conditional properties for text styles.

Allows text style properties like font, color, and size to change based on conditions.

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

Table of Contents

Interfaces

ConditionalInterface
Interface for all conditional objects.

Properties

$backgroundColor  : string|null
The background color.
$conditions  : array<int, Condition>
The conditions that must be met.
$fontName  : string|null
The font name.
$fontSize  : int|null
The font size in points.
$fontStyle  : string|null
The font style.
$fontWeight  : int|null
The font weight.
$fontWidth  : string|null
The font width.
$lineHeight  : float|null
The line height in points.
$textAlignment  : string|null
The text alignment.
$textColor  : string|null
The text color.
$textShadow  : array<string, mixed>|null
The text shadow.
$tracking  : float|null
The letter spacing (tracking).

Methods

addCondition()  : $this
Add a condition.
compactSize()  : self
Create a smaller text style for compact screens.
darkMode()  : self
Create a dark mode text style.
hasConditions()  : bool
Check if any conditions have been set.
jsonSerialize()  : array<string, mixed>
{@inheritdoc}
lightMode()  : self
Create a light mode text style.
setBackgroundColor()  : $this
Set the background color.
setFontName()  : $this
Set the font name.
setFontSize()  : $this
Set the font size.
setFontStyle()  : $this
Set the font style.
setFontWeight()  : $this
Set the font weight.
setFontWidth()  : $this
Set the font width.
setLineHeight()  : $this
Set the line height.
setTextAlignment()  : $this
Set the text alignment.
setTextColor()  : $this
Set the text color.
setTextShadow()  : $this
Set the text shadow.
setTracking()  : $this
Set the tracking (letter spacing).

Properties

Methods

compactSize()

Create a smaller text style for compact screens.

public static compactSize(int $fontSize) : self
Parameters
$fontSize : int

The smaller font size.

Return values
self —

A new instance.

darkMode()

Create a dark mode text style.

public static darkMode(string $textColor) : self
Parameters
$textColor : string

The dark mode text color.

Return values
self —

A new instance.

hasConditions()

Check if any conditions have been set.

public hasConditions() : bool
Return values
bool —

True if conditions exist.

jsonSerialize()

{@inheritdoc}

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

lightMode()

Create a light mode text style.

public static lightMode(string $textColor) : self
Parameters
$textColor : string

The light mode text color.

Return values
self —

A new instance.

setBackgroundColor()

Set the background color.

public setBackgroundColor(string $color) : $this
Parameters
$color : string

The color in hex format.

Return values
$this

setFontName()

Set the font name.

public setFontName(string $fontName) : $this
Parameters
$fontName : string

The font name.

Return values
$this

setFontSize()

Set the font size.

public setFontSize(int $size) : $this
Parameters
$size : int

The size in points.

Return values
$this

setFontStyle()

Set the font style.

public setFontStyle(string $style) : $this
Parameters
$style : string

The style ('normal', 'italic', 'oblique').

Return values
$this

setFontWeight()

Set the font weight.

public setFontWeight(int $weight) : $this
Parameters
$weight : int

The weight (100-900).

Return values
$this

setFontWidth()

Set the font width.

public setFontWidth(string $width) : $this
Parameters
$width : string

The width value.

Return values
$this

setLineHeight()

Set the line height.

public setLineHeight(float $height) : $this
Parameters
$height : float

The line height in points.

Return values
$this

setTextAlignment()

Set the text alignment.

public setTextAlignment(string $alignment) : $this
Parameters
$alignment : string

One of 'left', 'center', 'right', 'justified'.

Return values
$this

setTextColor()

Set the text color.

public setTextColor(string $color) : $this
Parameters
$color : string

The color in hex format.

Return values
$this

setTextShadow()

Set the text shadow.

public setTextShadow(array<string, mixed> $shadow) : $this
Parameters
$shadow : array<string, mixed>

The shadow configuration.

Return values
$this

setTracking()

Set the tracking (letter spacing).

public setTracking(float $tracking) : $this
Parameters
$tracking : float

The tracking value.

Return values
$this

        
On this page

Search results