Curried wrappers around PHP’s native string functions — every one of them is a value-first callable that binds the “how” up front so the subject string can be fed in later. Drop them into
array_map, compose them into pipelines, or use them as predicates for filters.
$shoutWrap = F\compose(
Str\trim(),
'strtoupper',
Str\wrap('[ ', ' ]')
);
$shoutWrap(' hello '); // '[ HELLO ]'Also: append, prepend, replaceWith, replaceSubString, findToReplace, translateWith, pad, repeat, slice, stripTags.
$containsFoo = Str\contains('foo');
$containsFoo('its foo'); // true
$containsFoo('its bar'); // false
Str\isBlank(''); // true
Str\isBlank(' '); // false — whitespace is not blank
Str\isBlank(null); // false — only a zero-length string countsAlso: startsWith, endsWith, containsPattern.
$splitCsv = Str\split(',');
$splitCsv('a,b,c'); // ['a', 'b', 'c']
$firstPos = Str\firstPosition('e');
$firstPos('hello'); // 1
$firstPos('world'); // NULL — not foundAlso: splitByLength, splitPattern, lastPosition, firstSubString, firstChar, lastChar, countChars, countSubString.
composeSafeStringFunc — compose several string-returning callables with an is_string guard between every step. stringCompiler — an accumulator for building strings across successive calls.
trim, lTrim, rTrim, wordWrap, wordCount, digit (number formatting → string), vSprintf, chunk, addSlashes, similar.
digit for number formatting inside a larger chain.