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

Stringable

Implements

Uses

Properties

protected

$value string

The underlying string value.

Default: null

Methods

public

__construct ( $value ) : void

Create a new instance of the class.

Parameters

  • $value string
public

after ( $search ) : static

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

Parameters

  • $search string
public

afterLast ( $search ) : static

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

Parameters

  • $search string
public

append ( $values ) : static

Append the given values to the string.

Parameters

  • $values array
public

ascii ( $language ) : static

Transliterate a UTF-8 value to ASCII.

Parameters

  • $language string
public

basename ( $suffix ) : static

Get the trailing name component of the path.

Parameters

  • $suffix string
public

classBasename ( ) : static

Get the basename of the class path.

public

before ( $search ) : static

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

Parameters

  • $search string
public

beforeLast ( $search ) : static

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

Parameters

  • $search string
public

between ( $from , $to ) : static

Get the portion of a string between two given values.

Parameters

  • $from string
  • $to string
public

camel ( ) : static

Convert a value to camel case.

public

contains ( $needles ) : bool

Determine if a given string contains a given substring.

Parameters

  • $needles string|array
public

containsAll ( array $needles ) : bool

Determine if a given string contains all array values.

Parameters

  • $needles array
public

dirname ( $levels ) : static

Get the parent directory's path.

Parameters

  • $levels int
public

endsWith ( $needles ) : bool

Determine if a given string ends with a given substring.

Parameters

  • $needles string|array
public

exactly ( $value ) : bool

Determine if the string is an exact match with the given value.

Parameters

  • $value string
public

explode ( $delimiter , $limit ) : Collection

Explode the string into an array.

Parameters

  • $delimiter string
  • $limit int
public

split ( $pattern , $limit , $flags ) : Collection

Split a string using a regular expression or by length.

Parameters

  • $pattern string|int
  • $limit int
  • $flags int
public

finish ( $cap ) : static

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

Parameters

  • $cap string
public

is ( $pattern ) : bool

Determine if a given string matches a given pattern.

Parameters

  • $pattern string|array
public

isAscii ( ) : bool

Determine if a given string is 7 bit ASCII.

public

isUuid ( ) : bool

Determine if a given string is a valid UUID.

public

isEmpty ( ) : bool

Determine if the given string is empty.

public

isNotEmpty ( ) : bool

Determine if the given string is not empty.

public

kebab ( ) : static

Convert a string to kebab case.

public

length ( $encoding ) : int

Return the length of the given string.

Parameters

  • $encoding string
public

limit ( $limit , $end ) : static

Limit the number of characters in a string.

Parameters

  • $limit int
  • $end string
public

lower ( ) : static

Convert the given string to lower-case.

public

markdown ( array $options ) : static

Convert GitHub flavored Markdown into HTML.

Parameters

  • $options array
public

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

Masks a portion of a string with a repeated character.

Parameters

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

match ( $pattern ) : static

Get the string matching the given pattern.

Parameters

  • $pattern string
public

matchAll ( $pattern ) : Collection

Get the string matching the given pattern.

Parameters

  • $pattern string
public

test ( $pattern ) : bool

Determine if the string matches the given pattern.

Parameters

  • $pattern string
public

padBoth ( $length , $pad ) : static

Pad both sides of the string with another.

Parameters

  • $length int
  • $pad string
public

padLeft ( $length , $pad ) : static

Pad the left side of the string with another.

Parameters

  • $length int
  • $pad string
public

padRight ( $length , $pad ) : static

Pad the right side of the string with another.

Parameters

  • $length int
  • $pad string
public

parseCallback ( $default ) : array

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

Parameters

  • $default string|null
public

pipe ( callable $callback ) : static

Call the given callback and return a new string.

Parameters

  • $callback callable
public

plural ( $count ) : static

Get the plural form of an English word.

Parameters

  • $count int
public

pluralStudly ( $count ) : static

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

Parameters

  • $count int
public

prepend ( $values ) : static

Prepend the given values to the string.

Parameters

  • $values array
public

remove ( $search , $caseSensitive ) : static

Remove any occurrence of the given string in the subject.

Parameters

  • $search string|string[]
  • $caseSensitive bool
public

reverse ( ) : static

Reverse the string.

public

repeat ( int $times ) : static

Repeat the string.

Parameters

  • $times int
public

replace ( $search , $replace ) : static

Replace the given value in the given string.

Parameters

  • $search string|string[]
  • $replace string|string[]
public

replaceArray ( $search , array $replace ) : static

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

Parameters

  • $search string
  • $replace array
public

replaceFirst ( $search , $replace ) : static

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

Parameters

  • $search string
  • $replace string
public

replaceLast ( $search , $replace ) : static

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

Parameters

  • $search string
  • $replace string
public

replaceMatches ( $pattern , $replace , $limit ) : static

Replace the patterns matching the given regular expression.

Parameters

  • $pattern string
  • $replace Closure |string
  • $limit int
public

scan ( $format ) : Collection

Parse input from a string to a collection, according to a format.

Parameters

  • $format string
public

start ( $prefix ) : static

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

Parameters

  • $prefix string
public

stripTags ( $allowedTags ) : static

Strip HTML and PHP tags from the given string.

Parameters

  • $allowedTags string
public

upper ( ) : static

Convert the given string to upper-case.

public

title ( ) : static

Convert the given string to title case.

public

headline ( ) : static

Convert the given string to title case for each word.

public

singular ( ) : static

Get the singular form of an English word.

public

slug ( $separator , $language ) : static

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

Parameters

  • $separator string
  • $language string|null
public

snake ( $delimiter ) : static

Convert a string to snake case.

Parameters

  • $delimiter string
public

startsWith ( $needles ) : bool

Determine if a given string starts with a given substring.

Parameters

  • $needles string|array
public

studly ( ) : static

Convert a value to studly caps case.

public

substr ( $start , $length ) : static

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

Parameters

  • $start int
  • $length int|null
public

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

Returns the number of substring occurrences.

Parameters

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

substrReplace ( $replace , $offset , $length ) : static

Replace text within a portion of a string.

Parameters

  • $replace string|array
  • $offset array|int
  • $length array|int|null
public

swap ( array $map ) : static

Swap multiple keywords in a string with other keywords.

Parameters

  • $map array
public

trim ( $characters ) : static

Trim the string of the given characters.

Parameters

  • $characters string
public

ltrim ( $characters ) : static

Left trim the string of the given characters.

Parameters

  • $characters string
public

rtrim ( $characters ) : static

Right trim the string of the given characters.

Parameters

  • $characters string
public

ucfirst ( ) : static

Make a string's first character uppercase.

public

ucsplit ( ) : Collection

Split a string by uppercase characters.

public

whenContains ( $needles , $callback , $default ) : static

Execute the given callback if the string contains a given substring.

Parameters

  • $needles string|array
  • $callback callable
  • $default callable|null
public

whenContainsAll ( array $needles , $callback , $default ) : static

Execute the given callback if the string contains all array values.

Parameters

  • $needles array
  • $callback callable
  • $default callable|null
public

whenEmpty ( $callback , $default ) : static

Execute the given callback if the string is empty.

Parameters

  • $callback callable
  • $default callable|null
public

whenNotEmpty ( $callback , $default ) : static

Execute the given callback if the string is not empty.

Parameters

  • $callback callable
  • $default callable|null
public

whenEndsWith ( $needles , $callback , $default ) : static

Execute the given callback if the string ends with a given substring.

Parameters

  • $needles string|array
  • $callback callable
  • $default callable|null
public

whenExactly ( $value , $callback , $default ) : static

Execute the given callback if the string is an exact match with the given value.

Parameters

  • $value string
  • $callback callable
  • $default callable|null
public

whenIs ( $pattern , $callback , $default ) : static

Execute the given callback if the string matches a given pattern.

Parameters

  • $pattern string|array
  • $callback callable
  • $default callable|null
public

whenIsAscii ( $callback , $default ) : static

Execute the given callback if the string is 7 bit ASCII.

Parameters

  • $callback callable
  • $default callable|null
public

whenIsUuid ( $callback , $default ) : static

Execute the given callback if the string is a valid UUID.

Parameters

  • $callback callable
  • $default callable|null
public

whenStartsWith ( $needles , $callback , $default ) : static

Execute the given callback if the string starts with a given substring.

Parameters

  • $needles string|array
  • $callback callable
  • $default callable|null
public

whenTest ( $pattern , $callback , $default ) : static

Execute the given callback if the string matches the given pattern.

Parameters

  • $pattern string
  • $callback callable
  • $default callable|null
public

words ( $words , $end ) : static

Limit the number of words in a string.

Parameters

  • $words int
  • $end string
public

wordCount ( ) : int

Get the number of words a string contains.

public

toHtmlString ( ) : HtmlString

Convert the string into a HtmlString instance.

public

dump ( ) : $this

Dump the string.

public

dd ( ) : never

Dump the string and end the script.

public

jsonSerialize ( ) : string

Convert the object to a string when JSON encoded.

public

__get ( $key ) : mixed

Proxy dynamic properties onto methods.

Parameters

  • $key string
public

__toString ( ) : string

Get the raw string value.