StringFragmentSplitter
Splits a string into RAW and EXPRESSION fragments.
EXPRESSION fragments are resolved by provided arbitrary regex pattern.
Table of Contents
Constants
- FLAG_UNMATCHED_AS_NULL = 1
- Returns `null` in case there have not been any pattern matches, if omitted an array containing only `raw` fragments is returned
- TYPE_EXPRESSION = 'expression'
- Literals used as expression
- TYPE_RAW = 'raw'
- Raw string literals
Properties
- $patterns : array<int, StringFragmentPattern>
Methods
- __construct() : mixed
- split() : StringFragmentCollection|null
- preparePatterns() : array<int, string>
Constants
FLAG_UNMATCHED_AS_NULL
Returns `null` in case there have not been any pattern matches, if omitted an array containing only `raw` fragments is returned
public
mixed
FLAG_UNMATCHED_AS_NULL
= 1
TYPE_EXPRESSION
Literals used as expression
public
mixed
TYPE_EXPRESSION
= 'expression'
TYPE_RAW
Raw string literals
public
mixed
TYPE_RAW
= 'raw'
Properties
$patterns read-only
protected
array<int, StringFragmentPattern>
$patterns
Methods
__construct()
public
__construct(StringFragmentPattern ...$patterns) : mixed
Parameters
- $patterns : StringFragmentPattern
split()
public
split(string $value[, int $flags = 0 ]) : StringFragmentCollection|null
Parameters
- $value : string
-
to be split into
raw
andexpression
fragments - $flags : int = 0
-
(optional)
FLAG_UNMATCHED_AS_NULL
Return values
StringFragmentCollection|nullpreparePatterns()
protected
preparePatterns() : array<int, string>