LFT
  • Namespace
  • Class
  • Tree

Namespaces

  • Docoflow
    • Contracts
    • Entity
    • Facades
    • Models
    • Traits
  • Docolight
    • Agno
      • Traits
    • Container
    • Http
      • Contracts
    • Rest
      • Handler
      • Http
    • Support
      • Debug
      • Traits
  • Docotory
    • Traits
  • None

Classes

  • ActiveRecordWrapper
  • Arr
  • Carbonate
  • ClassLoader
  • Collection
  • CollectionDataProvider
  • Facade
  • Factory
  • Fluent
  • Html
  • IterablePager
  • Repository
  • Set
  • Str

Class Str

String helper.

Docolight\Support\Str uses Docolight\Support\Traits\Macroable
Namespace: Docolight\Support
Author: Krisan Alfa Timur krisanalfa@docotel.co.id
Located at Docolight/Support/Str.php

Methods summary

public static string
# camel( string $value )

Convert a value to camel case.

Convert a value to camel case.

Parameters

$value

Returns

string
public static boolean
# contains( string $haystack, string|array $needles )

Determine if a given string contains a given substring.

Determine if a given string contains a given substring.

Parameters

$haystack
$needles

Returns

boolean
public static boolean
# endsWith( string $haystack, string|array $needles )

Determine if a given string ends with a given substring.

Determine if a given string ends with a given substring.

Parameters

$haystack
$needles

Returns

boolean
public static string
# finish( string $value, string $cap )

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

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

Parameters

$value
$cap

Returns

string
public static boolean
# is( string $pattern, string $value )

Determine if a given string matches a given pattern.

Determine if a given string matches a given pattern.

Parameters

$pattern
$value

Returns

boolean
public static integer
# length( string $value )

Return the length of the given string.

Return the length of the given string.

Parameters

$value

Returns

integer
public static string
# limit( string $value, integer $limit = 100, string $end = '...' )

Limit the number of characters in a string.

Limit the number of characters in a string.

Parameters

$value
$limit
$end

Returns

string
public static string
# lower( string $value )

Convert the given string to lower-case.

Convert the given string to lower-case.

Parameters

$value

Returns

string
public static string
# words( string $value, integer $words = 100, string $end = '...' )

Limit the number of words in a string.

Limit the number of words in a string.

Parameters

$value
$words
$end

Returns

string
public static array
# parseCallback( string $callback, string $default )

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

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

Parameters

$callback
$default

Returns

array
public static string
# random( integer $length = 16 )

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

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

Parameters

$length

Returns

string

Throws

RuntimeException
public static string
# randomBytes( integer $length = 16 )

Generate a more truly "random" bytes.

Generate a more truly "random" bytes.

Parameters

$length

Returns

string

Throws

RuntimeException
public static string
# quickRandom( integer $length = 16 )

Generate a "random" alpha-numeric string.

Generate a "random" alpha-numeric string.

Should not be considered sufficient for cryptography, etc.

Parameters

$length

Returns

string
public static boolean
# equals( string $knownString, string $userInput )

Compares two strings using a constant-time algorithm.

Compares two strings using a constant-time algorithm.

Note: This method will leak length information.

Note: Adapted from Symfony\Component\Security\Core\Util\StringUtils.

Parameters

$knownString
$userInput

Returns

boolean
public static string
# upper( string $value )

Convert the given string to upper-case.

Convert the given string to upper-case.

Parameters

$value

Returns

string
public static string
# title( string $value )

Convert the given string to title case.

Convert the given string to title case.

Parameters

$value

Returns

string
public static string
# slug( string $title, string $separator = '-' )

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

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

Parameters

$title
$separator

Returns

string
public static string
# snake( string $value, string $delimiter = '_' )

Convert a string to snake case.

Convert a string to snake case.

Parameters

$value
$delimiter

Returns

string
public static boolean
# startsWith( string $haystack, string|array $needles )

Determine if a given string starts with a given substring.

Determine if a given string starts with a given substring.

Parameters

$haystack
$needles

Returns

boolean
public static string
# studly( string $value )

Convert a value to studly caps case.

Convert a value to studly caps case.

Parameters

$value

Returns

string
public static mixed
# first( string $string, string $separator )

Get first section of a string after we split them by a specific separator.

Get first section of a string after we split them by a specific separator.

Parameters

$string
$separator

Returns

mixed
public static mixed
# last( string $string, string $separator )

Get last section of a string after we split them by a specific separator.

Get last section of a string after we split them by a specific separator.

Parameters

$string
$separator

Returns

mixed

Methods used from Docolight\Support\Traits\Macroable

__call(), __callStatic(), hasMacro(), macro()

Properties summary

protected static array $snakeCache

The cache of snake-cased words.

The cache of snake-cased words.

# []
protected static array $camelCache

The cache of camel-cased words.

The cache of camel-cased words.

# []
protected static array $studlyCache

The cache of studly-cased words.

The cache of studly-cased words.

# []

Properties used from Docolight\Support\Traits\Macroable

$macros

LFT API documentation generated by ApiGen