Properties

$methodArgs

$methodArgs : string[]

A mapping of method names to the numbers of arguments it accepts. Each should be two more than the equivalent Stringy method. Necessary as static methods place the optional $encoding as the last parameter.

Type

string[]

Methods

__callStatic()

__callStatic(string  $name, array  $arguments) : \Stringy\Stringy

Creates an instance of Stringy and invokes the given method with the rest of the passed arguments. The optional encoding is expected to be the last argument. For example, the following: StaticStringy::slice('fòôbàř', 0, 3, 'UTF-8'); translates to Stringy::create('fòôbàř', 'UTF-8')->slice(0, 3); The result is not cast, so the return value may be of type Stringy, integer, boolean, etc.

Parameters

string $name
array $arguments

Throws

\BadMethodCallException

Returns

\Stringy\Stringy —

append()

append(string  $str, string  $stringAppend, string  $encoding = null) : string

Parameters

string $str
string $stringAppend
string $encoding = null

Returns

string —

at()

at(string  $str, int  $index, string  $encoding = null) : string

Parameters

string $str
int $index
string $encoding = null

Returns

string —

between()

between(string  $str, string  $start, string  $end, int  $offset = 0, string  $encoding = null) : string

Parameters

string $str
string $start
string $end
int $offset = 0
string $encoding = null

Returns

string —

camelize()

camelize(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

chars()

chars(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

collapseWhitespace()

collapseWhitespace(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

contains()

contains(string  $str, string  $needle, bool  $caseSensitive = true, string  $encoding = null) : bool

Parameters

string $str
string $needle
bool $caseSensitive = true
string $encoding = null

Returns

bool —

containsAll()

containsAll(string  $str, string[]  $needle, bool  $caseSensitive = true, string  $encoding = null) : bool

Parameters

string $str
string[] $needle
bool $caseSensitive = true
string $encoding = null

Returns

bool —

containsAny()

containsAny(string  $str, string[]  $needle, bool  $caseSensitive = true, string  $encoding = null) : bool

Parameters

string $str
string[] $needle
bool $caseSensitive = true
string $encoding = null

Returns

bool —

count()

count(string  $str, string  $encoding = null) : int

Parameters

string $str
string $encoding = null

Returns

int —

countSubstr()

countSubstr(string  $str, string  $substring, bool  $caseSensitive = true, string  $encoding = null) : int

Parameters

string $str
string $substring
bool $caseSensitive = true
string $encoding = null

Returns

int —

dasherize()

dasherize(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

delimit()

delimit(string  $str, string  $delimiter, string  $encoding = null) : string

Parameters

string $str
string $delimiter
string $encoding = null

Returns

string —

endsWith()

endsWith(string  $str, string  $substring, bool  $caseSensitive = true, string  $encoding = null) : bool

Parameters

string $str
string $substring
bool $caseSensitive = true
string $encoding = null

Returns

bool —

endsWithAny()

endsWithAny(string  $str, string[]  $substrings, bool  $caseSensitive = true, string  $encoding = null) : bool

Parameters

string $str
string[] $substrings
bool $caseSensitive = true
string $encoding = null

Returns

bool —

ensureLeft()

ensureLeft(string  $str, string  $substring, string  $encoding = null) : string

Parameters

string $str
string $substring
string $encoding = null

Returns

string —

ensureRight()

ensureRight(string  $str, string  $substring, string  $encoding = null) : string

Parameters

string $str
string $substring
string $encoding = null

Returns

string —

first()

first(string  $str, int  $n, string  $encoding = null) : string

Parameters

string $str
int $n
string $encoding = null

Returns

string —

hasLowerCase()

hasLowerCase(string  $str, string  $encoding = null) : bool

Parameters

string $str
string $encoding = null

Returns

bool —

hasUpperCase()

hasUpperCase(string  $str, string  $encoding = null) : bool

Parameters

string $str
string $encoding = null

Returns

bool —

htmlDecode()

htmlDecode(string  $str, int  $flags = ENT_COMPAT, string  $encoding = null) : string

Parameters

string $str
int $flags = ENT_COMPAT
string $encoding = null

Returns

string —

htmlEncode()

htmlEncode(string  $str, int  $flags = ENT_COMPAT, string  $encoding = null) : string

Parameters

string $str
int $flags = ENT_COMPAT
string $encoding = null

Returns

string —

humanize()

humanize(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

indexOf()

indexOf(string  $str, string  $needle, int  $offset = 0, string  $encoding = null) : int

Parameters

string $str
string $needle
int $offset = 0
string $encoding = null

Returns

int —

indexOfLast()

indexOfLast(string  $str, string  $needle, int  $offset = 0, string  $encoding = null) : int

Parameters

string $str
string $needle
int $offset = 0
string $encoding = null

Returns

int —

insert()

insert(string  $str, string  $substring, int  $index = 0, string  $encoding = null) : string

Parameters

string $str
string $substring
int $index = 0
string $encoding = null

Returns

string —

isAlpha()

isAlpha(string  $str, string  $encoding = null) : bool

Parameters

string $str
string $encoding = null

Returns

bool —

isAlphanumeric()

isAlphanumeric(string  $str, string  $encoding = null) : bool

Parameters

string $str
string $encoding = null

Returns

bool —

isBase64()

isBase64(string  $str, string  $encoding = null) : bool

Parameters

string $str
string $encoding = null

Returns

bool —

isBlank()

isBlank(string  $str, string  $encoding = null) : bool

Parameters

string $str
string $encoding = null

Returns

bool —

isHexadecimal()

isHexadecimal(string  $str, string  $encoding = null) : bool

Parameters

string $str
string $encoding = null

Returns

bool —

isJson()

isJson(string  $str, string  $encoding = null) : bool

Parameters

string $str
string $encoding = null

Returns

bool —

isLowerCase()

isLowerCase(string  $str, string  $encoding = null) : bool

Parameters

string $str
string $encoding = null

Returns

bool —

isSerialized()

isSerialized(string  $str, string  $encoding = null) : bool

Parameters

string $str
string $encoding = null

Returns

bool —

isUpperCase()

isUpperCase(string  $str, string  $encoding = null) : bool

Parameters

string $str
string $encoding = null

Returns

bool —

last()

last(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

length()

length(string  $str, string  $encoding = null) : int

Parameters

string $str
string $encoding = null

Returns

int —

lines()

lines(string  $str, string  $encoding = null) : string[]

Parameters

string $str
string $encoding = null

Returns

string[] —

longestCommonPrefix()

longestCommonPrefix(string  $str, string  $otherStr, string  $encoding = null) : string

Parameters

string $str
string $otherStr
string $encoding = null

Returns

string —

longestCommonSuffix()

longestCommonSuffix(string  $str, string  $otherStr, string  $encoding = null) : string

Parameters

string $str
string $otherStr
string $encoding = null

Returns

string —

longestCommonSubstring()

longestCommonSubstring(string  $str, string  $otherStr, string  $encoding = null) : string

Parameters

string $str
string $otherStr
string $encoding = null

Returns

string —

lowerCaseFirst()

lowerCaseFirst(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

pad()

pad(string  $str, int  $length, string  $padStr = ' ', string  $padType = 'right', string  $encoding = null) : string

Parameters

string $str
int $length
string $padStr = ' '
string $padType = 'right'
string $encoding = null

Returns

string —

padBoth()

padBoth(string  $str, int  $length, string  $padStr = ' ', string  $encoding = null) : string

Parameters

string $str
int $length
string $padStr = ' '
string $encoding = null

Returns

string —

padLeft()

padLeft(string  $str, int  $length, string  $padStr = ' ', string  $encoding = null) : string

Parameters

string $str
int $length
string $padStr = ' '
string $encoding = null

Returns

string —

padRight()

padRight(string  $str, int  $length, string  $padStr = ' ', string  $encoding = null) : string

Parameters

string $str
int $length
string $padStr = ' '
string $encoding = null

Returns

string —

prepend()

prepend(string  $str, string  $string, string  $encoding = null) : string

Parameters

string $str
string $string
string $encoding = null

Returns

string —

regexReplace()

regexReplace(string  $str, string  $pattern, string  $replacement, string  $options = 'msr', string  $encoding = null) : string

Parameters

string $str
string $pattern
string $replacement
string $options = 'msr'
string $encoding = null

Returns

string —

removeLeft()

removeLeft(string  $str, string  $substring, string  $encoding = null) : string

Parameters

string $str
string $substring
string $encoding = null

Returns

string —

removeRight()

removeRight(string  $str, string  $substring, string  $encoding = null) : string

Parameters

string $str
string $substring
string $encoding = null

Returns

string —

repeat()

repeat(string  $str, int  $multiplier, string  $encoding = null) : string

Parameters

string $str
int $multiplier
string $encoding = null

Returns

string —

replace()

replace(string  $str, string  $search, string  $replacement, string  $encoding = null) : string

Parameters

string $str
string $search
string $replacement
string $encoding = null

Returns

string —

reverse()

reverse(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

safeTruncate()

safeTruncate(string  $str, int  $length, string  $substring = '', string  $encoding = null) : string

Parameters

string $str
int $length
string $substring = ''
string $encoding = null

Returns

string —

shuffle()

shuffle(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

slugify()

slugify(string  $str, string  $replacement = '-', string  $encoding = null) : string

Parameters

string $str
string $replacement = '-'
string $encoding = null

Returns

string —

slice()

slice(string  $str, int  $start, int  $end = null, string  $encoding = null) : string

Parameters

string $str
int $start
int $end = null
string $encoding = null

Returns

string —

split()

split(string  $str, string  $pattern, int  $limit = null, string  $encoding = null) : string

Parameters

string $str
string $pattern
int $limit = null
string $encoding = null

Returns

string —

startsWith()

startsWith(string  $str, string  $substring, bool  $caseSensitive = true, string  $encoding = null) : bool

Parameters

string $str
string $substring
bool $caseSensitive = true
string $encoding = null

Returns

bool —

startsWithAny()

startsWithAny(string  $str, string[]  $substrings, bool  $caseSensitive = true, string  $encoding = null) : bool

Parameters

string $str
string[] $substrings
bool $caseSensitive = true
string $encoding = null

Returns

bool —

stripWhitespace()

stripWhitespace(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

substr()

substr(string  $str, int  $start, int  $length = null, string  $encoding = null) : string

Parameters

string $str
int $start
int $length = null
string $encoding = null

Returns

string —

surround()

surround(string  $str, string  $substring, string  $encoding = null) : string

Parameters

string $str
string $substring
string $encoding = null

Returns

string —

swapCase()

swapCase(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

tidy()

tidy(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

titleize()

titleize(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

toAscii()

toAscii(string  $str, string  $language = 'en', bool  $removeUnsupported = true, string  $encoding = null) : string

Parameters

string $str
string $language = 'en'
bool $removeUnsupported = true
string $encoding = null

Returns

string —

toBoolean()

toBoolean(string  $str, string  $encoding = null) : bool

Parameters

string $str
string $encoding = null

Returns

bool —

toLowerCase()

toLowerCase(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

toSpaces()

toSpaces(string  $str, int  $tabLength = 4, string  $encoding = null) : string

Parameters

string $str
int $tabLength = 4
string $encoding = null

Returns

string —

toTabs()

toTabs(string  $str, int  $tabLength = 4, string  $encoding = null) : string

Parameters

string $str
int $tabLength = 4
string $encoding = null

Returns

string —

toTitleCase()

toTitleCase(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

toUpperCase()

toUpperCase(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

trim()

trim(string  $str, string  $chars = null, string  $encoding = null) : string

Parameters

string $str
string $chars = null
string $encoding = null

Returns

string —

trimLeft()

trimLeft(string  $str, string  $chars = null, string  $encoding = null) : string

Parameters

string $str
string $chars = null
string $encoding = null

Returns

string —

trimRight()

trimRight(string  $str, string  $chars = null, string  $encoding = null) : string

Parameters

string $str
string $chars = null
string $encoding = null

Returns

string —

truncate()

truncate(string  $str, int  $length, string  $substring = '', string  $encoding = null) : string

Parameters

string $str
int $length
string $substring = ''
string $encoding = null

Returns

string —

underscored()

underscored(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

upperCamelize()

upperCamelize(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —

upperCaseFirst()

upperCaseFirst(string  $str, string  $encoding = null) : string

Parameters

string $str
string $encoding = null

Returns

string —