Eno\Field » value
value() → value or null
value($options) → value or null
value($loader) → value or null
value($loader, $options) → value or null
Retrieve the value of a Field, optionally passing it through a loader
function and/or supplying options.
enoflag color: beige
towel color:
|
php$document = Parser::parse($input);
$flag_color = $document->element('flag color');
$towel_color = $document->element('towel color');
$flag_color->value(); // returns 'beige'
$towel_color->value(); // returns null
$flag_color->value(function($value) { return str_replace('eig', 'lu' , $value); }); // returns 'blue'
Parameters
$loaderA function returning the transformed/validated value or throwing an error.
(The function's argument signature is dynamic, you can either use ($value) or
($name, $value))
enforce_value
Whether there must be a value or the field is allowed to be empty (default to false)
required
Alias for enforce_value (this exists on many methods and depending on context refers to either element or value)
Return value
The (optionally transformed/validated) value of this Field.