class Illuminate / Support / Str

Str

Uses

Properties

protected static

$snakeCache array

The cache of snake-cased words.

Default: []
protected static

$camelCache array

The cache of camel-cased words.

Default: []
protected static

$studlyCache array

The cache of studly-cased words.

Default: []
protected static

$uuidFactory callable|null

The callback that should be used to generate UUIDs.

Default: null
protected static

$randomStringFactory callable|null

The callback that should be used to generate random strings.

Default: null

Methods

public static

of ( $string ) : Stringable

Get a new stringable object from the given string.

Parameters

  • $string string
public static

after ( $subject , $search ) : string

Return the remainder of a string after the first occurrence of a given value.

Parameters

  • $subject string
  • $search string
public static

afterLast ( $subject , $search ) : string

Return the remainder of a string after the last occurrence of a given value.

Parameters

  • $subject string
  • $search string
public static

ascii ( $value , $language ) : string

Transliterate a UTF-8 value to ASCII.

Parameters

  • $value string
  • $language string
public static

transliterate ( $string , $unknown , $strict ) : string

Transliterate a string to its closest ASCII representation.

Parameters

  • $string string
  • $unknown string|null
  • $strict bool|null
public static

before ( $subject , $search ) : string

Get the portion of a string before the first occurrence of a given value.

Parameters

  • $subject string
  • $search string
public static

beforeLast ( $subject , $search ) : string

Get the portion of a string before the last occurrence of a given value.

Parameters

  • $subject string
  • $search string
public static

between ( $subject , $from , $to ) : string

Get the portion of a string between two given values.

Parameters

  • $subject string
  • $from string
  • $to string
public static

betweenFirst ( $subject , $from , $to ) : string

Get the smallest possible portion of a string between two given values.

Parameters

  • $subject string
  • $from string
  • $to string
public static

camel ( $value ) : string

Convert a value to camel case.

Parameters

  • $value string
public static

charAt ( $subject , $index ) : string|false

Get the character at the specified index.

Parameters

  • $subject string
  • $index int
public static

contains ( $haystack , $needles , $ignoreCase ) : bool

Determine if a given string contains a given substring.

Parameters

  • $haystack string
  • $needles string|iterable
  • $ignoreCase bool
public static

containsAll ( $haystack , $needles , $ignoreCase ) : bool

Determine if a given string contains all array values.

Parameters

  • $haystack string
  • $needles iterable
  • $ignoreCase bool
public static

endsWith ( $haystack , $needles ) : bool

Determine if a given string ends with a given substring.

Parameters

  • $haystack string
  • $needles string|iterable
public static

excerpt ( $text , $phrase , $options ) : string|null

Extracts an excerpt from text that matches the first instance of a phrase.

Parameters

  • $text string
  • $phrase string
  • $options array
public static

finish ( $value , $cap ) : string

Cap a string with a single instance of a given value.

Parameters

  • $value string
  • $cap string
public static

wrap ( $value , $before , $after ) : string

Wrap the string with the given strings.

Parameters

  • $value string
  • $before string
  • $after string|null
public static

is ( $pattern , $value ) : bool

Determine if a given string matches a given pattern.

Parameters

  • $pattern string|iterable
  • $value string
public static

isAscii ( $value ) : bool

Determine if a given string is 7 bit ASCII.

Parameters

  • $value string
public static

isJson ( $value ) : bool

Determine if a given value is valid JSON.

Parameters

  • $value mixed
public static

isUrl ( $value , array $protocols ) : bool

Determine if a given value is a valid URL.

Parameters

  • $value mixed
  • $protocols array
public static

isUuid ( $value ) : bool

Determine if a given value is a valid UUID.

Parameters

  • $value mixed
public static

isUlid ( $value ) : bool

Determine if a given value is a valid ULID.

Parameters

  • $value mixed
public static

kebab ( $value ) : string

Convert a string to kebab case.

Parameters

  • $value string
public static

length ( $value , $encoding ) : int

Return the length of the given string.

Parameters

  • $value string
  • $encoding string|null
public static

limit ( $value , $limit , $end ) : string

Limit the number of characters in a string.

Parameters

  • $value string
  • $limit int
  • $end string
public static

lower ( $value ) : string

Convert the given string to lower-case.

Parameters

  • $value string
public static

words ( $value , $words , $end ) : string

Limit the number of words in a string.

Parameters

  • $value string
  • $words int
  • $end string
public static

markdown ( $string , array $options ) : string

Converts GitHub flavored Markdown into HTML.

Parameters

  • $string string
  • $options array
public static

inlineMarkdown ( $string , array $options ) : string

Converts inline Markdown into HTML.

Parameters

  • $string string
  • $options array
public static

mask ( $string , $character , $index , $length , $encoding ) : string

Masks a portion of a string with a repeated character.

Parameters

  • $string string
  • $character string
  • $index int
  • $length int|null
  • $encoding string
public static

match ( $pattern , $subject ) : string

Get the string matching the given pattern.

Parameters

  • $pattern string
  • $subject string
public static

isMatch ( $pattern , $value ) : bool

Determine if a given string matches a given pattern.

Parameters

  • $pattern string|iterable
  • $value string
public static

matchAll ( $pattern , $subject ) : Illuminate\...\Collection

Get the string matching the given pattern.

Parameters

  • $pattern string
  • $subject string
public static

padBoth ( $value , $length , $pad ) : string

Pad both sides of a string with another.

Parameters

  • $value string
  • $length int
  • $pad string
public static

padLeft ( $value , $length , $pad ) : string

Pad the left side of a string with another.

Parameters

  • $value string
  • $length int
  • $pad string
public static

padRight ( $value , $length , $pad ) : string

Pad the right side of a string with another.

Parameters

  • $value string
  • $length int
  • $pad string
public static

parseCallback ( $callback , $default ) : array|null>

Parse a Class[@]method style callback into class and method.

Parameters

  • $callback string
  • $default string|null
public static

plural ( $value , $count ) : string

Get the plural form of an English word.

Parameters

public static

pluralStudly ( $value , $count ) : string

Pluralize the last word of an English, studly caps case string.

Parameters

public static

password ( $length , $letters , $numbers , $symbols , $spaces ) : string

Generate a random, secure password.

Parameters

  • $length int
  • $letters bool
  • $numbers bool
  • $symbols bool
  • $spaces bool
public static

random ( $length ) : string

Generate a more truly "random" alpha-numeric string.

Parameters

  • $length int
public static

createRandomStringsUsing ( callable $factory ) : void

Set the callable that will be used to generate random strings.

Parameters

  • $factory callable|null
public static

createRandomStringsUsingSequence ( array $sequence , $whenMissing ) : void

Set the sequence that will be used to generate random strings.

Parameters

  • $sequence array
  • $whenMissing callable|null
public static

createRandomStringsNormally ( ) : void

Indicate that random strings should be created normally and not using a custom factory.

public static

repeat ( string $string , int $times ) : string

Repeat the given string.

Parameters

  • $string string
  • $times int
public static

replaceArray ( $search , $replace , $subject ) : string

Replace a given value in the string sequentially with an array.

Parameters

  • $search string
  • $replace iterable
  • $subject string
public static

replace ( $search , $replace , $subject , $caseSensitive ) : string|string[]

Replace the given value in the given string.

Parameters

  • $search string|iterable
  • $replace string|iterable
  • $subject string|iterable
  • $caseSensitive bool
public static

replaceFirst ( $search , $replace , $subject ) : string

Replace the first occurrence of a given value in the string.

Parameters

  • $search string
  • $replace string
  • $subject string
public static

replaceLast ( $search , $replace , $subject ) : string

Replace the last occurrence of a given value in the string.

Parameters

  • $search string
  • $replace string
  • $subject string
public static

remove ( $search , $subject , $caseSensitive ) : string

Remove any occurrence of the given string in the subject.

Parameters

  • $search string|iterable
  • $subject string|iterable
  • $caseSensitive bool
public static

reverse ( string $value ) : string

Reverse the given string.

Parameters

  • $value string
public static

start ( $value , $prefix ) : string

Begin a string with a single instance of a given value.

Parameters

  • $value string
  • $prefix string
public static

upper ( $value ) : string

Convert the given string to upper-case.

Parameters

  • $value string
public static

title ( $value ) : string

Convert the given string to title case.

Parameters

  • $value string
public static

headline ( $value ) : string

Convert the given string to title case for each word.

Parameters

  • $value string
public static

singular ( $value ) : string

Get the singular form of an English word.

Parameters

  • $value string
public static

slug ( $title , $separator , $language , $dictionary ) : string

Generate a URL friendly "slug" from a given string.

Parameters

  • $title string
  • $separator string
  • $language string|null
  • $dictionary array
public static

snake ( $value , $delimiter ) : string

Convert a string to snake case.

Parameters

  • $value string
  • $delimiter string
public static

squish ( $value ) : string

Remove all "extra" blank space from the given string.

Parameters

  • $value string
public static

startsWith ( $haystack , $needles ) : bool

Determine if a given string starts with a given substring.

Parameters

  • $haystack string
  • $needles string|iterable
public static

studly ( $value ) : string

Convert a value to studly caps case.

Parameters

  • $value string
public static

substr ( $string , $start , $length , $encoding ) : string

Returns the portion of the string specified by the start and length parameters.

Parameters

  • $string string
  • $start int
  • $length int|null
  • $encoding string
public static

substrCount ( $haystack , $needle , $offset , $length ) : int

Returns the number of substring occurrences.

Parameters

  • $haystack string
  • $needle string
  • $offset int
  • $length int|null
public static

substrReplace ( $string , $replace , $offset , $length ) : string|string[]

Replace text within a portion of a string.

Parameters

  • $string string|string[]
  • $replace string|string[]
  • $offset int|int[]
  • $length int|int[]|null
public static

swap ( array $map , $subject ) : string

Swap multiple keywords in a string with other keywords.

Parameters

  • $map array
  • $subject string
public static

lcfirst ( $string ) : string

Make a string's first character lowercase.

Parameters

  • $string string
public static

ucfirst ( $string ) : string

Make a string's first character uppercase.

Parameters

  • $string string
public static

ucsplit ( $string ) : string[]

Split a string into pieces by uppercase characters.

Parameters

  • $string string
public static

wordCount ( $string , $characters ) : int

Get the number of words a string contains.

Parameters

  • $string string
  • $characters string|null
public static

wordWrap ( $string , $characters , $break , $cutLongWords ) : string

Wrap a string to a given number of characters.

Parameters

  • $string string
  • $characters int
  • $break string
  • $cutLongWords bool
public static

uuid ( ) : Ramsey\...\UuidInterface

Generate a UUID (version 4).

public static

orderedUuid ( ) : Ramsey\...\UuidInterface

Generate a time-ordered UUID (version 4).

public static

createUuidsUsing ( callable $factory ) : void

Set the callable that will be used to generate UUIDs.

Parameters

  • $factory callable|null
public static

createUuidsUsingSequence ( array $sequence , $whenMissing ) : void

Set the sequence that will be used to generate UUIDs.

Parameters

  • $sequence array
  • $whenMissing callable|null
public static

freezeUuids ( Closure $callback ) : Ramsey\...\UuidInterface

Always return the same UUID when generating new UUIDs.

Parameters

public static

createUuidsNormally ( ) : void

Indicate that UUIDs should be created normally and not using a custom factory.

public static

ulid ( $time ) : Symfony\...\Ulid

Generate a ULID.

Parameters

public static

flushCache ( ) : void

Remove all strings from the casing caches.