class Illuminate / Support / Str
You are viewing an older version of the documentation. For the latest, please visit master documentation.

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

The callback that should be used to generate UUIDs.

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

camel ( $value ) : string

Convert a value to camel case.

Parameters

  • $value string
public static

contains ( $haystack , $needles ) : bool

Determine if a given string contains a given substring.

Parameters

  • $haystack string
  • $needles string|string[]
public static

containsAll ( $haystack , array $needles ) : bool

Determine if a given string contains all array values.

Parameters

  • $haystack string
  • $needles string[]
public static

endsWith ( $haystack , $needles ) : bool

Determine if a given string ends with a given substring.

Parameters

  • $haystack string
  • $needles string|string[]
public static

finish ( $value , $cap ) : string

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

Parameters

  • $value string
  • $cap string
public static

is ( $pattern , $value ) : bool

Determine if a given string matches a given pattern.

Parameters

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

isAscii ( $value ) : bool

Determine if a given string is 7 bit ASCII.

Parameters

  • $value string
public static

isUuid ( $value ) : bool

Determine if a given string is a valid UUID.

Parameters

  • $value string
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

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

matchAll ( $pattern , $subject ) : 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

random ( $length ) : string

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

Parameters

  • $length int
public static

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

Repeat the given string.

Parameters

  • $string string
  • $times int
public static

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

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

Parameters

  • $search string
  • $replace array|string,string>
  • $subject string
public static

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

Replace the given value in the given string.

Parameters

  • $search string|string[]
  • $replace string|string[]
  • $subject string|string[]
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|string[]
  • $subject string
  • $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 ) : string

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

Parameters

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

snake ( $value , $delimiter ) : string

Convert a string to snake case.

Parameters

  • $value string
  • $delimiter string
public static

startsWith ( $haystack , $needles ) : bool

Determine if a given string starts with a given substring.

Parameters

  • $haystack string
  • $needles string|string[]
public static

studly ( $value ) : string

Convert a value to studly caps case.

Parameters

  • $value string
public static

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

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

Parameters

  • $string string
  • $start int
  • $length int|null
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|array

Replace text within a portion of a string.

Parameters

  • $string string|array
  • $replace string|array
  • $offset array|int
  • $length array|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

ucfirst ( $string ) : string

Make a string's first character uppercase.

Parameters

  • $string string
public static

ucsplit ( $string ) : array

Split a string into pieces by uppercase characters.

Parameters

  • $string string
public static

wordCount ( $string ) : int

Get the number of words a string contains.

Parameters

  • $string string
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

createUuidsNormally ( ) : void

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

public static

flushCache ( ) : void

Remove all strings from the casing caches.