Enum extends Type implements TypeInterface
The Enum complex data type.
Tags
Interfaces, Classes and Traits
- TypeInterface
- The interface for all complex data types.
Table of Contents
- $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.
- __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() : mixed
- Set the validation helper text.
- setOptions() : mixed
- Setter for the enum options.
- setValue() : mixed
- 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
Return values
mixed —__toString()
Used to convert the object to a printable string.
public
__toString() : string
Tags
Return values
string —getHelper()
Used to get the validation helper message string.
public
getHelper() : string
Tags
Return values
string —getOptions()
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
string —setHelper()
Set the validation helper text.
public
setHelper(string $helper) : mixed
Parameters
- $helper : string
Tags
Return values
mixed —setOptions()
Setter for the enum options.
public
setOptions(array<string|int, mixed> $opts) : mixed
Parameters
- $opts : array<string|int, mixed>
Tags
Return values
mixed —setValue()
Used to select the current enum item.
public
setValue(string $item) : mixed
Parameters
- $item : string
-
The item to set as selected in the Enum