ConditionalDocumentStyle
in package
implements
ConditionalInterface
FinalYes
Conditional properties for document styles.
Allows document-level style properties to change based on conditions, typically used for dark mode support.
Tags
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.
Methods
- addCondition() : $this
- Add a condition.
- darkMode() : self
- Create a dark mode document style.
- hasConditions() : bool
- Check if any conditions have been set.
- jsonSerialize() : array<string, mixed>
- {@inheritdoc}
- lightMode() : self
- Create a light mode document style.
- setBackgroundColor() : $this
- Set the background color.
Properties
$backgroundColor
The background color.
private
string|null
$backgroundColor
= null
$conditions
The conditions that must be met.
private
array<int, Condition>
$conditions
= []
Methods
addCondition()
Add a condition.
public
addCondition(Condition $condition) : $this
Parameters
- $condition : Condition
-
The condition to add.
Return values
$thisdarkMode()
Create a dark mode document style.
public
static darkMode([string $backgroundColor = '#1C1C1E' ]) : self
Parameters
- $backgroundColor : string = '#1C1C1E'
-
The dark mode background 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 document style.
public
static lightMode([string $backgroundColor = '#FFFFFF' ]) : self
Parameters
- $backgroundColor : string = '#FFFFFF'
-
The light mode background 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.