AbstractString
in package
implements
Stringable, JsonSerializable
Represents a string of abstract characters.
Unicode defines 3 types of "characters" (bytes, code points and grapheme clusters). This class is the abstract type to use as a type-hint when the logic you want to implement doesn't care about the exact variant it deals with.
Tags
Interfaces, Classes and Traits
- Stringable
- JsonSerializable
Table of Contents
- PREG_OFFSET_CAPTURE = PREG_OFFSET_CAPTURE
- PREG_PATTERN_ORDER = PREG_PATTERN_ORDER
- PREG_SET_ORDER = PREG_SET_ORDER
- PREG_SPLIT = 0
- PREG_SPLIT_DELIM_CAPTURE = PREG_SPLIT_DELIM_CAPTURE
- PREG_SPLIT_NO_EMPTY = PREG_SPLIT_NO_EMPTY
- PREG_SPLIT_OFFSET_CAPTURE = PREG_SPLIT_OFFSET_CAPTURE
- PREG_UNMATCHED_AS_NULL = PREG_UNMATCHED_AS_NULL
- $ignoreCase : mixed
- $string : mixed
- __clone() : mixed
- __construct() : mixed
- __sleep() : array<string|int, mixed>
- __toString() : string
- after() : static
- afterLast() : static
- append() : static
- before() : static
- beforeLast() : static
- bytesAt() : array<string|int, int>
- camel() : static
- chunk() : array<string|int, static>
- collapseWhitespace() : static
- containsAny() : bool
- endsWith() : bool
- ensureEnd() : static
- ensureStart() : static
- equalsTo() : bool
- folded() : static
- ignoreCase() : static
- indexOf() : int|null
- indexOfLast() : int|null
- isEmpty() : bool
- join() : static
- jsonSerialize() : string
- length() : int
- lower() : static
- match() : array<string|int, mixed>
- Matches the string using a regular expression.
- padBoth() : static
- padEnd() : static
- padStart() : static
- prepend() : static
- repeat() : static
- replace() : static
- replaceMatches() : static
- reverse() : static
- slice() : static
- snake() : static
- splice() : static
- split() : array<string|int, static>
- startsWith() : bool
- title() : static
- toByteString() : ByteString
- toCodePointString() : CodePointString
- toString() : string
- toUnicodeString() : UnicodeString
- trim() : static
- trimEnd() : static
- trimStart() : static
- truncate() : static
- unwrap() : array<string|int, string>|array<string|int, mixed>
- Unwraps instances of AbstractString back to strings.
- upper() : static
- width() : int
- Returns the printable length on a terminal.
- wordwrap() : static
- wrap() : array<string|int, static>|array<string|int, mixed>
- Wraps (and normalizes) strings in instances of AbstractString.
Constants
PREG_OFFSET_CAPTURE
public
mixed
PREG_OFFSET_CAPTURE
= PREG_OFFSET_CAPTURE
PREG_PATTERN_ORDER
public
mixed
PREG_PATTERN_ORDER
= PREG_PATTERN_ORDER
PREG_SET_ORDER
public
mixed
PREG_SET_ORDER
= PREG_SET_ORDER
PREG_SPLIT
public
mixed
PREG_SPLIT
= 0
PREG_SPLIT_DELIM_CAPTURE
public
mixed
PREG_SPLIT_DELIM_CAPTURE
= PREG_SPLIT_DELIM_CAPTURE
PREG_SPLIT_NO_EMPTY
public
mixed
PREG_SPLIT_NO_EMPTY
= PREG_SPLIT_NO_EMPTY
PREG_SPLIT_OFFSET_CAPTURE
public
mixed
PREG_SPLIT_OFFSET_CAPTURE
= PREG_SPLIT_OFFSET_CAPTURE
PREG_UNMATCHED_AS_NULL
public
mixed
PREG_UNMATCHED_AS_NULL
= PREG_UNMATCHED_AS_NULL
Properties
$ignoreCase
protected
mixed
$ignoreCase
= false
$string
protected
mixed
$string
= ''
Methods
__clone()
public
__clone() : mixed
Return values
mixed —__construct()
public
abstract __construct([string $string = '' ]) : mixed
Parameters
- $string : string = ''
Return values
mixed —__sleep()
public
__sleep() : array<string|int, mixed>
Return values
array<string|int, mixed> —__toString()
public
__toString() : string
Return values
string —after()
public
after(string|array<string|int, string> $needle[, bool $includeNeedle = false ], int $offset) : static
Parameters
- $needle : string|array<string|int, string>
- $includeNeedle : bool = false
- $offset : int
Return values
static —afterLast()
public
afterLast(string|array<string|int, string> $needle[, bool $includeNeedle = false ], int $offset) : static
Parameters
- $needle : string|array<string|int, string>
- $includeNeedle : bool = false
- $offset : int
Return values
static —append()
public
abstract append(string ...$suffix) : static
Parameters
- $suffix : string
Return values
static —before()
public
before(string|array<string|int, string> $needle[, bool $includeNeedle = false ], int $offset) : static
Parameters
- $needle : string|array<string|int, string>
- $includeNeedle : bool = false
- $offset : int
Return values
static —beforeLast()
public
beforeLast(string|array<string|int, string> $needle[, bool $includeNeedle = false ], int $offset) : static
Parameters
- $needle : string|array<string|int, string>
- $includeNeedle : bool = false
- $offset : int
Return values
static —bytesAt()
public
bytesAt(int $offset) : array<string|int, int>
Parameters
- $offset : int
Return values
array<string|int, int> —camel()
public
abstract camel() : static
Return values
static —chunk()
public
abstract chunk([int $length = 1 ]) : array<string|int, static>
Parameters
- $length : int = 1
Return values
array<string|int, static> —collapseWhitespace()
public
collapseWhitespace() : static
Return values
static —containsAny()
public
containsAny(string|array<string|int, string> $needle) : bool
Parameters
- $needle : string|array<string|int, string>
Return values
bool —endsWith()
public
endsWith(string|array<string|int, string> $suffix) : bool
Parameters
- $suffix : string|array<string|int, string>
Return values
bool —ensureEnd()
public
ensureEnd(string $suffix) : static
Parameters
- $suffix : string
Return values
static —ensureStart()
public
ensureStart(string $prefix) : static
Parameters
- $prefix : string
Return values
static —equalsTo()
public
equalsTo(string|array<string|int, string> $string) : bool
Parameters
- $string : string|array<string|int, string>
Return values
bool —folded()
public
abstract folded() : static
Return values
static —ignoreCase()
public
ignoreCase() : static
Return values
static —indexOf()
public
indexOf(string|array<string|int, string> $needle, int $offset) : int|null
Parameters
- $needle : string|array<string|int, string>
- $offset : int
Return values
int|null —indexOfLast()
public
indexOfLast(string|array<string|int, string> $needle, int $offset) : int|null
Parameters
- $needle : string|array<string|int, string>
- $offset : int
Return values
int|null —isEmpty()
public
isEmpty() : bool
Return values
bool —join()
public
abstract join(array<string|int, mixed> $strings[, string $lastGlue = null ]) : static
Parameters
- $strings : array<string|int, mixed>
- $lastGlue : string = null
Return values
static —jsonSerialize()
public
jsonSerialize() : string
Return values
string —length()
public
abstract length() : int
Return values
int —lower()
public
abstract lower() : static
Return values
static —match()
Matches the string using a regular expression.
public
abstract match(string $regexp, int $flags, int $offset) : array<string|int, mixed>
Pass PREG_PATTERN_ORDER or PREG_SET_ORDER as $flags to get all occurrences matching the regular expression.
Parameters
- $regexp : string
- $flags : int
- $offset : int
Return values
array<string|int, mixed> —All matches in a multi-dimensional array ordered according to flags
padBoth()
public
abstract padBoth(int $length[, string $padStr = ' ' ]) : static
Parameters
- $length : int
- $padStr : string = ' '
Return values
static —padEnd()
public
abstract padEnd(int $length[, string $padStr = ' ' ]) : static
Parameters
- $length : int
- $padStr : string = ' '
Return values
static —padStart()
public
abstract padStart(int $length[, string $padStr = ' ' ]) : static
Parameters
- $length : int
- $padStr : string = ' '
Return values
static —prepend()
public
abstract prepend(string ...$prefix) : static
Parameters
- $prefix : string
Return values
static —repeat()
public
repeat(int $multiplier) : static
Parameters
- $multiplier : int
Return values
static —replace()
public
abstract replace(string $from, string $to) : static
Parameters
- $from : string
- $to : string
Return values
static —replaceMatches()
public
abstract replaceMatches(string $fromRegexp, string|callable $to) : static
Parameters
- $fromRegexp : string
- $to : string|callable
Return values
static —reverse()
public
abstract reverse() : static
Return values
static —slice()
public
abstract slice(int $start[, int $length = null ]) : static
Parameters
- $start : int
- $length : int = null
Return values
static —snake()
public
abstract snake() : static
Return values
static —splice()
public
abstract splice(string $replacement, int $start[, int $length = null ]) : static
Parameters
- $replacement : string
- $start : int
- $length : int = null
Return values
static —split()
public
split(string $delimiter[, int $limit = null ][, int $flags = null ]) : array<string|int, static>
Parameters
- $delimiter : string
- $limit : int = null
- $flags : int = null
Return values
array<string|int, static> —startsWith()
public
startsWith(string|array<string|int, string> $prefix) : bool
Parameters
- $prefix : string|array<string|int, string>
Return values
bool —title()
public
abstract title([bool $allWords = false ]) : static
Parameters
- $allWords : bool = false
Return values
static —toByteString()
public
toByteString([string $toEncoding = null ]) : ByteString
Parameters
- $toEncoding : string = null
Return values
ByteString —toCodePointString()
public
toCodePointString() : CodePointString
Return values
CodePointString —toString()
public
toString() : string
Return values
string —toUnicodeString()
public
toUnicodeString() : UnicodeString
Return values
UnicodeString —trim()
public
abstract trim([string $chars = "
" ]) : static
Parameters
- $chars : string = " "
Return values
static —trimEnd()
public
abstract trimEnd([string $chars = "
" ]) : static
Parameters
- $chars : string = " "
Return values
static —trimStart()
public
abstract trimStart([string $chars = "
" ]) : static
Parameters
- $chars : string = " "
Return values
static —truncate()
public
truncate(int $length[, string $ellipsis = '' ][, bool $cut = true ]) : static
Parameters
- $length : int
- $ellipsis : string = ''
- $cut : bool = true
Return values
static —unwrap()
Unwraps instances of AbstractString back to strings.
public
static unwrap(array<string|int, mixed> $values) : array<string|int, string>|array<string|int, mixed>
Parameters
- $values : array<string|int, mixed>
Return values
array<string|int, string>|array<string|int, mixed> —upper()
public
abstract upper() : static
Return values
static —width()
Returns the printable length on a terminal.
public
abstract width([bool $ignoreAnsiDecoration = true ]) : int
Parameters
- $ignoreAnsiDecoration : bool = true
Return values
int —wordwrap()
public
wordwrap([int $width = 75 ][, string $break = "
" ][, bool $cut = false ]) : static
Parameters
- $width : int = 75
- $break : string = " "
- $cut : bool = false
Return values
static —wrap()
Wraps (and normalizes) strings in instances of AbstractString.
public
static wrap(array<string|int, mixed> $values) : array<string|int, static>|array<string|int, mixed>
Parameters
- $values : array<string|int, mixed>