Copied!

OptionDefinition

OptionDefinition.php : 19
Read-only
Final

The {@see self::with*()} methods return a new instance validated as a whole, against the current default: to narrow the range or choices so that they exclude the default, clear it first, e.g. `$definition->withDefault(null)->withChoices(['low', 'high'])->withDefault('low')`.

Constants

publicDEFAULT_TRANSLATION_DOMAIN

OptionDefinition.php : 21
public string DEFAULT_TRANSLATION_DOMAIN = 'ibexa_connector_ai'

Properties

public $choices

OptionDefinition.php : 46
public array<string|int, mixed>|null $choices = null

public $default

OptionDefinition.php : 41
public mixed $default = null

public $help

OptionDefinition.php : 40
public string|null $help = null

public $label

OptionDefinition.php : 38
public string $label

public $max

OptionDefinition.php : 44
public int|float|null $max = null

public $min

OptionDefinition.php : 43
public int|float|null $min = null

public $name

OptionDefinition.php : 36
public string $name

public $payloadField

OptionDefinition.php : 48
public string|false|null $payloadField = null

public $position

OptionDefinition.php : 47
public int $position = 0

public $required

OptionDefinition.php : 42
public bool $required = false

public $scale

OptionDefinition.php : 45
public int|null $scale = null

public $translationDomain

OptionDefinition.php : 39
public string $translationDomain = self::DEFAULT_TRANSLATION_DOMAIN

public $type

OptionDefinition.php : 37
public OptionTypeInterface $type

Methods

publicaccepts()

OptionDefinition.php : 255
public accepts(mixed $value) : bool

Parameters

Name Type Default value Description
$value mixed - -

Return values

bool

publicallows()

OptionDefinition.php : 246

Whether a coerced value is within the range and among the choices of the option.

public allows(int|float|bool|string|array<string|int, mixed> $value) : bool

Parameters

Name Type Default value Description
$value int|float|bool|string|array<string|int, mixed> - -

Return values

bool

publicboolean()

OptionDefinition.php : 140
public static boolean(string $name, string $label[, bool|null $default = null ][, bool $required = false ][, string|null $help = null ][, int $position = 0 ][, string $translationDomain = \self::DEFAULT_TRANSLATION_DOMAIN ]) : self

Parameters

Name Type Default value Description
$name string - -
$label string - -
$default bool|null null -
$required bool false -
$help string|null null -
$position int 0 -
$translationDomain string OptionDefinition::DEFAULT_TRANSLATION_DOMAIN -

Return values

self

publicchoice()

OptionDefinition.php : 206
public static choice(string $name, string $label, array<string, string> $choices[, string|null $default = null ][, bool $required = false ][, string|null $help = null ][, int $position = 0 ][, string $translationDomain = \self::DEFAULT_TRANSLATION_DOMAIN ]) : self

Parameters

Name Type Default value Description
$name string - -
$label string - -
$choices array<string, string> - -
$default string|null null -
$required bool false -
$help string|null null -
$position int 0 -
$translationDomain string OptionDefinition::DEFAULT_TRANSLATION_DOMAIN -

Return values

self

publiccoerce()

OptionDefinition.php : 236

Converts a value to the option type, {@see self::allows()} checks its range and choices.

public coerce(mixed $value) : int|float|bool|string|array<string|int, mixed>

Parameters

Name Type Default value Description
$value mixed - -

Return values

int|float|bool|string|array<string|int, mixed>

Tags
Throws
InvalidOptionValueException

publicfloat()

OptionDefinition.php : 113
public static float(string $name, string $label[, float|null $default = null ][, float|null $min = null ][, float|null $max = null ][, int|null $scale = null ][, bool $required = false ][, string|null $help = null ][, int $position = 0 ][, string $translationDomain = \self::DEFAULT_TRANSLATION_DOMAIN ]) : self

Parameters

Name Type Default value Description
$name string - -
$label string - -
$default float|null null -
$min float|null null -
$max float|null null -
$scale int|null null -
$required bool false -
$help string|null null -
$position int 0 -
$translationDomain string OptionDefinition::DEFAULT_TRANSLATION_DOMAIN -

Return values

self

publicgetPayloadField()

OptionDefinition.php : 272
public getPayloadField() : string|null

Return values

string|null

null when the option is not sent to the provider

publichasDefault()

OptionDefinition.php : 264
public hasDefault() : bool

Return values

bool

publicinteger()

OptionDefinition.php : 88
public static integer(string $name, string $label[, int|null $default = null ][, int|null $min = null ][, int|null $max = null ][, bool $required = false ][, string|null $help = null ][, int $position = 0 ][, string $translationDomain = \self::DEFAULT_TRANSLATION_DOMAIN ]) : self

Parameters

Name Type Default value Description
$name string - -
$label string - -
$default int|null null -
$min int|null null -
$max int|null null -
$required bool false -
$help string|null null -
$position int 0 -
$translationDomain string OptionDefinition::DEFAULT_TRANSLATION_DOMAIN -

Return values

self

publicof()

OptionDefinition.php : 56
public static of(OptionTypeInterface $type, string $name, string $label[, mixed $default = null ][, bool $required = false ][, string|null $help = null ][, int|float|null $min = null ][, int|float|null $max = null ][, int|null $scale = null ][, array<string, string>|null $choices = null ][, int $position = 0 ][, string $translationDomain = \self::DEFAULT_TRANSLATION_DOMAIN ][, string|false|null $payloadField = null ]) : self

Parameters

Name Type Default value Description
$type OptionTypeInterface - -
$name string - -
$label string - -
$default mixed null -
$required bool false -
$help string|null null -
$min int|float|null null -
$max int|float|null null -
$scale int|null null -
$choices array<string, string>|null null -
$position int 0 -
$translationDomain string OptionDefinition::DEFAULT_TRANSLATION_DOMAIN -
$payloadField string|false|null null -

Return values

self

publicstring()

OptionDefinition.php : 161
public static string(string $name, string $label[, string|null $default = null ][, bool $required = false ][, string|null $help = null ][, int $position = 0 ][, string $translationDomain = \self::DEFAULT_TRANSLATION_DOMAIN ]) : self

Parameters

Name Type Default value Description
$name string - -
$label string - -
$default string|null null -
$required bool false -
$help string|null null -
$position int 0 -
$translationDomain string OptionDefinition::DEFAULT_TRANSLATION_DOMAIN -

Return values

self

publictext()

OptionDefinition.php : 182
public static text(string $name, string $label[, string|null $default = null ][, bool $required = false ][, string|null $help = null ][, int $position = 0 ][, string $translationDomain = \self::DEFAULT_TRANSLATION_DOMAIN ]) : self

Parameters

Name Type Default value Description
$name string - -
$label string - -
$default string|null null -
$required bool false -
$help string|null null -
$position int 0 -
$translationDomain string OptionDefinition::DEFAULT_TRANSLATION_DOMAIN -

Return values

self

publicwithChoices()

OptionDefinition.php : 324
public withChoices(array<int, string> $choiceKeys) : self

Parameters

Name Type Default value Description
$choiceKeys array<int, string> - -

Return values

self

publicwithDefault()

OptionDefinition.php : 281
public withDefault(mixed $default) : self

Parameters

Name Type Default value Description
$default mixed - -

Return values

self

publicwithPayloadField()

OptionDefinition.php : 355
public withPayloadField(string|false|null $payloadField) : self

Parameters

Name Type Default value Description
$payloadField string|false|null -

null = the option name, false = not sent

Return values

self

publicwithRange()

OptionDefinition.php : 300
public withRange(int|float|null $min, int|float|null $max) : self

Parameters

Name Type Default value Description
$min int|float|null - -
$max int|float|null - -

Return values

self