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¶
DEFAULT_TRANSLATION_DOMAIN ¶
OptionDefinition.php
:
21
|
|
|
Properties¶
$choices
¶
OptionDefinition.php
:
46
|
|
|
$default
¶
OptionDefinition.php
:
41
|
|
|
$help
¶
OptionDefinition.php
:
40
|
|
|
$label
¶
OptionDefinition.php
:
38
|
|
|
$max
¶
OptionDefinition.php
:
44
|
|
|
$min
¶
OptionDefinition.php
:
43
|
|
|
$name
¶
OptionDefinition.php
:
36
|
|
|
$payloadField
¶
OptionDefinition.php
:
48
|
|
|
$position
¶
OptionDefinition.php
:
47
|
|
|
$required
¶
OptionDefinition.php
:
42
|
|
|
$scale
¶
OptionDefinition.php
:
45
|
|
|
$translationDomain
¶
OptionDefinition.php
:
39
|
|
|
$type
¶
OptionDefinition.php
:
37
|
|
|
Methods¶
accepts()
¶
OptionDefinition.php
:
255
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $value | mixed | - | - |
Return values
bool
allows()
¶
OptionDefinition.php
:
246
Whether a coerced value is within the range and among the choices of the option.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $value | int|float|bool|string|array<string|int, mixed> | - | - |
Return values
bool
boolean()
¶
OptionDefinition.php
:
140
|
|
|
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
choice()
¶
OptionDefinition.php
:
206
|
|
|
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
coerce()
¶
OptionDefinition.php
:
236
Converts a value to the option type, {@see self::allows()} checks its range and choices.
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $value | mixed | - | - |
Return values
int|float|bool|string|array<string|int, mixed>
Tags
float()
¶
OptionDefinition.php
:
113
|
|
|
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
getPayloadField()
¶
OptionDefinition.php
:
272
|
|
|
Return values
string|null
null when the option is not sent to the provider
hasDefault()
¶
OptionDefinition.php
:
264
|
|
|
Return values
bool
integer()
¶
OptionDefinition.php
:
88
|
|
|
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
of()
¶
OptionDefinition.php
:
56
|
|
|
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
string()
¶
OptionDefinition.php
:
161
|
|
|
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
text()
¶
OptionDefinition.php
:
182
|
|
|
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
withChoices()
¶
OptionDefinition.php
:
324
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $choiceKeys | array<int, string> | - | - |
Return values
self
withDefault()
¶
OptionDefinition.php
:
281
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $default | mixed | - | - |
Return values
self
withPayloadField()
¶
OptionDefinition.php
:
355
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $payloadField | string|false|null | - |
null = the option name, false = not sent |
Return values
self
withRange()
¶
OptionDefinition.php
:
300
|
|
|
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| $min | int|float|null | - | - |
| $max | int|float|null | - | - |
Return values
self