Enum
extends Type
in package
implements
TypeInterface
The Enum complex data type.
Tags
Table of Contents
Interfaces
- TypeInterface
- The interface for all complex data types.
Properties
- $helper : string
- The message to display to the user when validation fails.
- $options : array<string|int, mixed>
- An array of valid enum options.
- $value : string
- The currently selected enum option.
Methods
- __construct() : mixed
- Constructor that sets up the enum options.
- __toString() : string
- Used to convert the object to a printable string.
- getHelper() : string
- Used to get the validation helper message string.
- getOptions() : array<string|int, mixed>
- Get the array of enum options.
- getValue() : string
- Used to get the current enum item.
- setHelper() : void
- Set the validation helper text.
- setOptions() : void
- Setter for the enum options.
- setValue() : void
- Used to select the current enum item.
Properties
$helper
The message to display to the user when validation fails.
protected
string
$helper
= 'Not a valid enum option!'
Tags
$options
An array of valid enum options.
private
array<string|int, mixed>
$options
Tags
$value
The currently selected enum option.
private
string
$value
= ''
Tags
Methods
__construct()
Constructor that sets up the enum options.
public
__construct([array<string|int, mixed> $opts = array('') ]) : mixed
Parameters
- $opts : array<string|int, mixed> = array('')
Tags
__toString()
Used to convert the object to a printable string.
public
__toString() : string
Tags
Return values
stringgetHelper()
Used to get the validation helper message string.
public
getHelper() : string
Tags
Return values
stringgetOptions()
Get the array of enum options.
public
getOptions([bool $alphaSort = false ]) : array<string|int, mixed>
Parameters
- $alphaSort : bool = false
-
Set to true if you want the Enum options in alphabetical order (default false)
Tags
Return values
array<string|int, mixed>getValue()
Used to get the current enum item.
public
getValue() : string
Tags
Return values
stringsetHelper()
Set the validation helper text.
public
setHelper(string $helper) : void
Parameters
- $helper : string
Tags
setOptions()
Setter for the enum options.
public
setOptions(array<string|int, mixed> $opts) : void
Parameters
- $opts : array<string|int, mixed>
Tags
setValue()
Used to select the current enum item.
public
setValue(mixed $item) : void
Parameters
- $item : mixed
-
The item to set as selected in the Enum