trait Themes

Constants

protected DEFAULT_THEME

The default theme name.

protected DEFAULT_THEMES

The default theme registry.

Properties

static protected string $theme

The name of the active theme.

static protected Prompt>, class-string<callable&object>>> $themes

The available themes.

Methods

static string
theme(string|null $name = null)

Get or set the active theme.

static void
addTheme(string $name, array $renderers)

Add a new theme.

callable
getRenderer()

Get the renderer for the current prompt.

string
renderTheme()

Render the prompt using the active theme.

static void
resetTheme()

Reset theme state to defaults.

Details

at line 112
static string theme(string|null $name = null)

Get or set the active theme.

Boot-only when setting. The active theme persists in a static property for the worker lifetime and applies to every subsequent prompt render.

Parameters

string|null $name

Return Value

string

Exceptions

InvalidArgumentException

at line 133
static void addTheme(string $name, array $renderers)

Add a new theme.

Boot-only. Themes persist in a static property for the worker lifetime and are available to every subsequent prompt render.

Parameters

string $name
array $renderers

Return Value

void

at line 145
protected callable getRenderer()

Get the renderer for the current prompt.

Return Value

callable

at line 155
protected string renderTheme()

Render the prompt using the active theme.

Return Value

string

at line 168
static void resetTheme()

Reset theme state to defaults.

Boot or tests only. Clears worker-wide prompt theme configuration; concurrent prompts may render with different themes depending on timing.

Return Value

void