class Choice extends Component (View source)

Properties

protected OutputStyle $output

The output style implementation.

from  Component
protected $mutators

The list of mutators to apply on the view data.

from  Component

Methods

void
__construct(OutputStyle $output)

Creates a new component instance.

void
renderView(string $view, Arrayable|array $data, int $verbosity)

Renders the given view.

void
compile(string $view, array $data)

Compile the given view contents.

array<int,string>|string
mutate(array<int,string>|string $data, $mutators)

Mutates the given data with the given set of mutators.

mixed
usingQuestionHelper(callable $callable)

Eventually performs a question using the component's question helper.

mixed
render(string $question, array<array-key,string> $choices, mixed $default = null, int $attempts = null, bool $multiple = false)

Renders the component using the given arguments.

ChoiceQuestion
getChoiceQuestion(string $question, array $choices, mixed $default)

Get a ChoiceQuestion instance that handles array keys like Prompts.

bool
isAssoc(array $array)

No description

Details

void __construct(OutputStyle $output)

Creates a new component instance.

Parameters

OutputStyle $output

Return Value

void

protected void renderView(string $view, Arrayable|array $data, int $verbosity)

Renders the given view.

Parameters

string $view
Arrayable|array $data
int $verbosity

Return Value

void

protected void compile(string $view, array $data)

Compile the given view contents.

Parameters

string $view
array $data

Return Value

void

protected array<int,string>|string mutate(array<int,string>|string $data, $mutators)

Mutates the given data with the given set of mutators.

Parameters

array<int,string>|string $data
$mutators

Return Value

array<int,string>|string

protected mixed usingQuestionHelper(callable $callable)

Eventually performs a question using the component's question helper.

Parameters

callable $callable

Return Value

mixed

mixed render(string $question, array<array-key,string> $choices, mixed $default = null, int $attempts = null, bool $multiple = false)

Renders the component using the given arguments.

Parameters

string $question
array<array-key,string> $choices
mixed $default
int $attempts
bool $multiple

Return Value

mixed

protected ChoiceQuestion getChoiceQuestion(string $question, array $choices, mixed $default)

Get a ChoiceQuestion instance that handles array keys like Prompts.

Parameters

string $question
array $choices
mixed $default

Return Value

ChoiceQuestion

protected bool isAssoc(array $array)

No description

Parameters

array $array

Return Value

bool