ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Refinery\String\SplitString Class Reference

Split a string by delimiter into array. More...

+ Inheritance diagram for ILIAS\Refinery\String\SplitString:
+ Collaboration diagram for ILIAS\Refinery\String\SplitString:

Public Member Functions

 __construct (string $delimiter, Factory $factory)
 
 transform ($from)
 @inheritDoc More...
 
 applyTo (Result $result)
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\Refinery\Transformation
 transform ($from)
 Perform the transformation. More...
 
 applyTo (Result $result)
 Perform the transformation and reify possible failures. More...
 
 __invoke ($from)
 Transformations should be callable. More...
 

Private Attributes

string $delimiter
 
Factory $factory
 

Detailed Description

Split a string by delimiter into array.

Definition at line 32 of file SplitString.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Refinery\String\SplitString::__construct ( string  $delimiter,
Factory  $factory 
)

Definition at line 39 of file SplitString.php.

40 {
41 $this->delimiter = $delimiter;
42 $this->factory = $factory;
43 }
factory()

References ILIAS\Refinery\String\SplitString\$delimiter, ILIAS\Refinery\String\SplitString\$factory, and factory().

+ Here is the call graph for this function:

Member Function Documentation

◆ applyTo()

ILIAS\Refinery\String\SplitString::applyTo ( Result  $result)

@inheritDoc

Implements ILIAS\Refinery\Transformation.

Definition at line 61 of file SplitString.php.

61 : Result
62 {
63 $dataValue = $result->value();
64 if (false === is_string($dataValue)) {
65 $exception = new InvalidArgumentException(__METHOD__ . " the argument is not a string.");
66 return $this->factory->error($exception);
67 }
68
69 $value = explode($this->delimiter, $dataValue);
70 return $this->factory->ok($value);
71 }

References factory(), and ILIAS\Data\Result\value().

+ Here is the call graph for this function:

◆ transform()

ILIAS\Refinery\String\SplitString::transform (   $from)

@inheritDoc

Returns
string[]

Implements ILIAS\Refinery\Transformation.

Definition at line 49 of file SplitString.php.

49 : array
50 {
51 if (!is_string($from)) {
52 throw new InvalidArgumentException(__METHOD__ . " the argument is not a string.");
53 }
54
55 return explode($this->delimiter, $from);
56 }

Field Documentation

◆ $delimiter

string ILIAS\Refinery\String\SplitString::$delimiter
private

Definition at line 36 of file SplitString.php.

Referenced by ILIAS\Refinery\String\SplitString\__construct().

◆ $factory

Factory ILIAS\Refinery\String\SplitString::$factory
private

Definition at line 37 of file SplitString.php.

Referenced by ILIAS\Refinery\String\SplitString\__construct().


The documentation for this class was generated from the following file: