\Symfony\Component\StringAbstractString

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.

Summary

Methods
Properties
Constants
__construct()
unwrap()
wrap()
after()
afterLast()
append()
before()
beforeLast()
bytesAt()
camel()
chunk()
collapseWhitespace()
containsAny()
endsWith()
ensureEnd()
ensureStart()
equalsTo()
folded()
ignoreCase()
indexOf()
indexOfLast()
isEmpty()
join()
jsonSerialize()
length()
lower()
match()
padBoth()
padEnd()
padStart()
prepend()
repeat()
replace()
replaceMatches()
reverse()
slice()
snake()
splice()
split()
startsWith()
title()
toByteString()
toCodePointString()
toString()
toUnicodeString()
trim()
trimEnd()
trimStart()
truncate()
upper()
width()
wordwrap()
__sleep()
__clone()
__toString()
No public properties found
PREG_PATTERN_ORDER
PREG_SET_ORDER
PREG_OFFSET_CAPTURE
PREG_UNMATCHED_AS_NULL
PREG_SPLIT
PREG_SPLIT_NO_EMPTY
PREG_SPLIT_DELIM_CAPTURE
PREG_SPLIT_OFFSET_CAPTURE
No protected methods found
$string
$ignoreCase
N/A
No private methods found
No private properties found
N/A

Constants

PREG_PATTERN_ORDER

PREG_PATTERN_ORDER = \PREG_PATTERN_ORDER

PREG_SET_ORDER

PREG_SET_ORDER = \PREG_SET_ORDER

PREG_OFFSET_CAPTURE

PREG_OFFSET_CAPTURE = \PREG_OFFSET_CAPTURE

PREG_UNMATCHED_AS_NULL

PREG_UNMATCHED_AS_NULL = \PREG_UNMATCHED_AS_NULL

PREG_SPLIT

PREG_SPLIT = 0

PREG_SPLIT_NO_EMPTY

PREG_SPLIT_NO_EMPTY = \PREG_SPLIT_NO_EMPTY

PREG_SPLIT_DELIM_CAPTURE

PREG_SPLIT_DELIM_CAPTURE = \PREG_SPLIT_DELIM_CAPTURE

PREG_SPLIT_OFFSET_CAPTURE

PREG_SPLIT_OFFSET_CAPTURE = \PREG_SPLIT_OFFSET_CAPTURE

Properties

$string

$string

$ignoreCase

$ignoreCase

Methods

__construct()

__construct(string  $string = '') : mixed

Parameters

string $string

Returns

mixed —

unwrap()

unwrap(array  $values) : string[]|array

Unwraps instances of AbstractString back to strings.

Parameters

array $values

Returns

string[]|array —

wrap()

wrap(array  $values) : static[]|array

Wraps (and normalizes) strings in instances of AbstractString.

Parameters

array $values

Returns

static[]|array —

after()

after(string|string[]  $needle, bool  $includeNeedle = false, int  $offset) : static

Parameters

string|string[] $needle
bool $includeNeedle
int $offset

Returns

static —

afterLast()

afterLast(string|string[]  $needle, bool  $includeNeedle = false, int  $offset) : static

Parameters

string|string[] $needle
bool $includeNeedle
int $offset

Returns

static —

append()

append(string  ...$suffix) : static

Parameters

string $suffix variadic

Returns

static —

before()

before(string|string[]  $needle, bool  $includeNeedle = false, int  $offset) : static

Parameters

string|string[] $needle
bool $includeNeedle
int $offset

Returns

static —

beforeLast()

beforeLast(string|string[]  $needle, bool  $includeNeedle = false, int  $offset) : static

Parameters

string|string[] $needle
bool $includeNeedle
int $offset

Returns

static —

bytesAt()

bytesAt(int  $offset) : int[]

Parameters

int $offset

Returns

int[] —

camel()

camel() : static

Returns

static —

chunk()

chunk(int  $length = 1) : static[]

Parameters

int $length

Returns

static[] —

collapseWhitespace()

collapseWhitespace() : static

Returns

static —

containsAny()

containsAny(string|string[]  $needle) : bool

Parameters

string|string[] $needle

Returns

bool —

endsWith()

endsWith(string|string[]  $suffix) : bool

Parameters

string|string[] $suffix

Returns

bool —

ensureEnd()

ensureEnd(string  $suffix) : static

Parameters

string $suffix

Returns

static —

ensureStart()

ensureStart(string  $prefix) : static

Parameters

string $prefix

Returns

static —

equalsTo()

equalsTo(string|string[]  $string) : bool

Parameters

string|string[] $string

Returns

bool —

folded()

folded() : static

Returns

static —

ignoreCase()

ignoreCase() : static

Returns

static —

indexOf()

indexOf(string|string[]  $needle, int  $offset) : ?int

Parameters

string|string[] $needle
int $offset

Returns

?int —

indexOfLast()

indexOfLast(string|string[]  $needle, int  $offset) : ?int

Parameters

string|string[] $needle
int $offset

Returns

?int —

isEmpty()

isEmpty() : bool

Returns

bool —

join()

join(array  $strings, string  $lastGlue = null) : static

Parameters

array $strings
string $lastGlue

Returns

static —

jsonSerialize()

jsonSerialize() : string

Returns

string —

length()

length() : int

Returns

int —

lower()

lower() : static

Returns

static —

match()

match(string  $regexp, int  $flags, int  $offset) : array

Matches the string using a regular expression.

Pass PREG_PATTERN_ORDER or PREG_SET_ORDER as $flags to get all occurrences matching the regular expression.

Parameters

string $regexp
int $flags
int $offset

Returns

array —

All matches in a multi-dimensional array ordered according to flags

padBoth()

padBoth(int  $length, string  $padStr = ' ') : static

Parameters

int $length
string $padStr

Returns

static —

padEnd()

padEnd(int  $length, string  $padStr = ' ') : static

Parameters

int $length
string $padStr

Returns

static —

padStart()

padStart(int  $length, string  $padStr = ' ') : static

Parameters

int $length
string $padStr

Returns

static —

prepend()

prepend(string  ...$prefix) : static

Parameters

string $prefix variadic

Returns

static —

repeat()

repeat(int  $multiplier) : static

Parameters

int $multiplier

Returns

static —

replace()

replace(string  $from, string  $to) : static

Parameters

string $from
string $to

Returns

static —

replaceMatches()

replaceMatches(string  $fromRegexp, string|callable  $to) : static

Parameters

string $fromRegexp
string|callable $to

Returns

static —

reverse()

reverse() : static

Returns

static —

slice()

slice(int  $start, int  $length = null) : static

Parameters

int $start
int $length

Returns

static —

snake()

snake() : static

Returns

static —

splice()

splice(string  $replacement, int  $start, int  $length = null) : static

Parameters

string $replacement
int $start
int $length

Returns

static —

split()

split(string  $delimiter, int  $limit = null, int  $flags = null) : static[]

Parameters

string $delimiter
int $limit
int $flags

Returns

static[] —

startsWith()

startsWith(string|string[]  $prefix) : bool

Parameters

string|string[] $prefix

Returns

bool —

title()

title(bool  $allWords = false) : static

Parameters

bool $allWords

Returns

static —

toByteString()

toByteString(string  $toEncoding = null) : \Symfony\Component\String\ByteString

Parameters

string $toEncoding

Returns

\Symfony\Component\String\ByteString —

toCodePointString()

toCodePointString() : \Symfony\Component\String\CodePointString

Returns

\Symfony\Component\String\CodePointString —

toString()

toString() : string

Returns

string —

toUnicodeString()

toUnicodeString() : \Symfony\Component\String\UnicodeString

Returns

\Symfony\Component\String\UnicodeString —

trim()

trim(string  $chars = " 	

 ") : static

Parameters

string $chars

Returns

static —

trimEnd()

trimEnd(string  $chars = " 	

 ") : static

Parameters

string $chars

Returns

static —

trimStart()

trimStart(string  $chars = " 	

 ") : static

Parameters

string $chars

Returns

static —

truncate()

truncate(int  $length, string  $ellipsis = '', bool  $cut = true) : static

Parameters

int $length
string $ellipsis
bool $cut

Returns

static —

upper()

upper() : static

Returns

static —

width()

width(bool  $ignoreAnsiDecoration = true) : int

Returns the printable length on a terminal.

Parameters

bool $ignoreAnsiDecoration

Returns

int —

wordwrap()

wordwrap(int  $width = 75, string  $break = "
", bool  $cut = false) : static

Parameters

int $width
string $break
bool $cut

Returns

static —

__sleep()

__sleep() : array

Returns

array —

__clone()

__clone() : mixed

Returns

mixed —

__toString()

__toString() : string

Returns

string —