40 if (!is_string($from)) {
41 throw new \InvalidArgumentException(__METHOD__ .
" the argument is not a string.");
44 return explode($this->delimiter, $from);
60 $dataValue = $data->
value();
61 if (
false === is_string($dataValue)) {
62 $exception = new \InvalidArgumentException(__METHOD__ .
" the argument is not a string.");
63 return $this->factory->error($exception);
66 $value = explode($this->delimiter, $dataValue);
67 return $this->factory->ok($value);
value()
Get the encapsulated value.
__construct($delimiter, Factory $factory)
applyTo(Result $data)
Perform the transformation and reify possible failures.If $data->isError(), the method MUST do nothin...
Split a string by delimiter into array.
A result encapsulates a value or an error and simplifies the handling of those.
transform($from)
Perform the transformation.Please use this for transformations. It's more performant than calling inv...
__invoke($from)
Transformations should be callable.This MUST do the same as transform.