Float, Boolean, YesNoBoolean, StringParser::defaultsToIfEmpty
This release includes several new types contributed by @yuvalherziger
boolean
("0"
/"1"
,"true"
,"false"
=>true
/false
)yesNoBoolean
("yes"
,"no"
=>true
/false
)float
("0.1"
=>0.1
There's also a new way to deal with empty strings. You can now tell the string()
parser to also use the provided default value when the given string is empty (currently the default value is only used when the string is not given at all).
So
$value = $this->queryParameter(..)->string()->defaultsToIfEmpty('empty')
is equivalent to
$value = $this->queryParameter(..)->string()->defaultsTo('empty');
if ($value == "")
$value = 'empty';