← All Modules

Methods

string

camelize

camelize(string, lowercased)

Parameters:

  • string
  • lowercased

Converts string to camelcase notation. Second parameter sets the first letter to lowercase or uppercase.

capitalize

capitalize(string)

Parameters:

  • string

Converts first letter of the string to uppercase.

celsius

celsius(string)

Parameters:

  • string

Converts temperature in Fahrenheit and Kelvin notation to Celsius degree. When passed string is a number, appends °C to the string.

chomp

chomp(string, pattern)

Parameters:

  • string
  • pattern

Removes from the end of the string passed pattern.

chop

chop(string)

Parameters:

  • string

Returns string with last character removed. If the string ends with line ending characters then both will be removed.

classify

classify(string)

Parameters:

  • string

Creates a class name based on the string.

constantize

constantize(string)

Parameters:

  • string

Converts string to constant notation.

crop

crop(string, length, append)

Parameters:

  • string
  • length
  • append

Truncates string at full words. Adds ... if the string is longer than the second parameter.

dasherize

dasherize(string)

Parameters:

  • string

Replaces _ with -.

dot

dot(string)

Parameters:

  • string

Returns string with dot at the end.

fahrenheit

fahrenheit(string)

Parameters:

  • string

Converts temperature in Celsius and Kelvin notation to Fahrenheit degree. When passed string is a number, appends °F to the string.

htmlstrip

htmlstrip(string)

Parameters:

  • string

Removes HTML tags from a string. Warning: user input might include malicious content, htmlstrip is not a silver bullet against xss.

humanize

humanize(string, capitalize = true)

Parameters:

  • string
  • capitalize = true

Replaces _ with singlespaces. When capitalize is truthy, converts first char of the string to uppercase.

hyphenate

hyphenate(string)

Parameters:

  • string

Replaces spaces with hyphens, splits camelcase text, remove non-word chars and converts string to lowercase.

index

index(string, pattern, start = 0)

Parameters:

  • string
  • pattern
  • start = 0

Returns index of searched pattern.

initials

initials(string, separator = "")

Parameters:

  • string
  • separator = ""

Returns initials separated by the separator.

kelvin

kelvin(string)

Parameters:

  • string

Converts temperature in Celsius and Fahrenheit notation to Kelvin scale. When passed string is a number, appends K to the string.

lowercase

lowercase(string)

Parameters:

  • string

Lowercases the string.

lowerfirst

lowerfirst(string)

Parameters:

  • string

Converts first letter of the string to lowercase.

ltrim

ltrim(string, characters = " ")

Parameters:

  • string
  • characters = " "

Removes white space characters or other specified in parameter characters from the beginning of the string.

pad

pad(string, pad, left = true)

Parameters:

  • string
  • pad
  • left = true

Returns string with added pad from left side or right side.

pluralize

pluralize(string)

Parameters:

  • string

Returns plural form of the string.

repeat

repeat(string, count)

Parameters:

  • string
  • count

Repeats the string n times.

replace

replace(string, pattern, replace)

Parameters:

  • string
  • pattern
  • replace

Replaces searched pattern by the last parameter.

rtrim

rtrim(string, characters = " ")

Parameters:

  • string
  • characters = " "

Removes white space characters or other specified in parameter characters from the end of the string.

singlespace

singlespace(string)

Parameters:

  • string

Replaces in the string multiple spaces to single spaces.

singularize

singularize(string, appendix = "")

Parameters:

  • string
  • appendix = ""

Returns singular form of the string.

slugify

slugify(string, separator = "-")

Parameters:

  • string
  • separator = "-"

Converts string to lower case, remove non-word chars and replace spaces with the separator.

split

split(string, separator = "")

Parameters:

  • string
  • separator = ""

Splits string into an array by separating the string into substrings.

strip

strip(string, pattern)

Parameters:

  • string
  • pattern

Removes the passed pattern from the string.

squeeze

squeeze(string, pattern = "a-zA-Z")

Parameters:

  • string
  • pattern = "a-zA-Z"

Replaces multiple occurances of the same characters to the one character.

summarize

summarize(string, length = 100)

Parameters:

  • string
  • length = 100

Adds three dots at the end of the string, when the string is longer than the passed length.

swapcase

swapcase(string)

Parameters:

  • string

Replaces in string lowercased letters to uppercase and uppercased letters to lowercase.

tail

tail(string, length = 30, ending = "...")

Parameters:

  • string
  • length = 30
  • ending = "..."

Truncates the tail of a given string.

titleize

titleize(string)

Parameters:

  • string

Converts to 'uppercase' first letter of each word in string.

trim

trim(string)

Parameters:

  • string

Removes whitespace from the start and the end of the string.

truncate

truncate(string, length = 30, ending = "...")

Parameters:

  • string
  • length = 30
  • ending = "..."

Truncates a given string if it longer than the passed length and replaces last chars of new string with the passed ending.

quote

quote(string, lang = "en")

Parameters:

  • string
  • lang = "en"

Puts the string inside quotations marks.

uid

uid(length = 32)

Parameters:

  • length = 32

Returns an unique identifier.

underscore

underscore(string)

Parameters:

  • string

Returns new string with words separated by _. All letters are lowercased.

unquote

unquote(string)

Parameters:

  • string

Removes "" or „” from the string.

unwrap

unwrap(string, first, last = first)

Parameters:

  • string
  • first
  • last = first

Removes characters from the start and end of the string based on the passed values.

uppercase

uppercase(string)

Parameters:

  • string

Converts string to uppercase.

unescape

unescape(string)

Parameters:

  • string

Converts the HTML entities to their corresponding characters.

whitespacestrip

whitespacestrip(string)

Parameters:

  • string

Removes whitespaces from the string.

wrap

wrap(string, first, last = first)

Parameters:

  • string
  • first
  • last = first

Wraps string between the first and last parameters.

bytes

bytes(string)

Parameters:

  • string

Converts string with specific unit to bytes.

prettybytes

prettybytes(bytes)

Parameters:

  • bytes

Converts bytes to a human-readable string with binary units (KiB, MiB, GiB, etc.).