Methods summary
protected static
string
|
#
encoding( )
Get the appliction.encoding without needing to request it from Config::get()
each time.
Get the appliction.encoding without needing to request it from Config::get()
each time.
Returns
string
|
public static
integer
|
#
length( string $value )
Get the length of a string.
Get the length of a string.
$length = Str::length('Taylor Otwell');
$length = Str::length('Τάχιστη')
Parameters
Returns
integer
|
public static
string
|
#
lower( string $value )
Convert a string to lowercase.
Convert a string to lowercase.
$lower = Str::lower('Taylor Otwell');
$lower = Str::lower('Τάχιστη');
Parameters
Returns
string
|
public static
string
|
#
upper( string $value )
Convert a string to uppercase.
Convert a string to uppercase.
$upper = Str::upper('Taylor Otwell');
$upper = Str::upper('Τάχιστη');
Parameters
Returns
string
|
public static
string
|
#
title( string $value )
Convert a string to title case (ucwords equivalent).
Convert a string to title case (ucwords equivalent).
$title = Str::title('taylor otwell');
$title = Str::title('νωθρού κυνός');
Parameters
Returns
string
|
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.
echo Str::limit('Taylor Otwell', 3);
echo Str::limit('Taylor Otwell', 3, '---');
Parameters
- $value
string $value
- $limit
integer $limit
- $end
string $end
Returns
string
|
public static
string
|
#
limit_exact( string $value, integer $limit = 100, string $end = '...' )
Limit the number of chracters in a string including custom ending
Limit the number of chracters in a string including custom ending
echo Str::limit_exact('Taylor Otwell', 9);
echo Str::limit_exact('Taylor Otwell', 9, '---');
Parameters
- $value
string $value
- $limit
integer $limit
- $end
string $end
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.
echo Str::words('This is a sentence.', 3);
echo Str::words('This is a sentence.', 3, '---');
Parameters
- $value
string $value
- $words
integer $words
- $end
string $end
Returns
string
|
public static
string
|
#
singular( string $value )
Get the singular form of the given word.
Get the singular form of the given word.
Parameters
Returns
string
|
public static
string
|
#
plural( string $value, integer $count = 2 )
Get the plural form of the given word.
Get the plural form of the given word.
$plural = Str::plural('child', 10);
$plural = Str::plural('octocat', 1);
Parameters
- $value
string $value
- $count
integer $count
Returns
string
|
protected static
Laravel\Pluralizer
|
#
pluralizer( )
Get the pluralizer instance.
Get the pluralizer instance.
Returns
|
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.
$slug = Str::slug('This is my blog post!');
$slug = Str::slug('This is my blog post!', '_');
Parameters
- $title
string $title
- $separator
string $separator
Returns
string
|
public static
string
|
#
ascii( string $value )
Convert a string to 7-bit ASCII.
Convert a string to 7-bit ASCII.
This is helpful for converting UTF-8 strings for usage in URLs, etc.
Parameters
Returns
string
|
public static
string
|
#
classify( string $value )
Convert a string to an underscored, camel-cased class name.
Convert a string to an underscored, camel-cased class name.
This method is primarily used to format task and controller names.
$class = Str::classify('task_name');
$class = Str::classify('taylor otwell')
Parameters
Returns
string
|
public static
array
|
#
segments( string $value )
Return the "URI" style segments in a given string.
Return the "URI" style segments in a given string.
Parameters
Returns
array
|
public static
string
|
#
random( integer $length, string $type = 'alnum' )
Generate a random alpha or alpha-numeric string.
Generate a random alpha or alpha-numeric string.
<code> // Generate a 40 character random alpha-numeric string echo
Str::random(40);
// Generate a 16 character random alphabetic string echo Str::random(16,
'alpha'); <code>
Parameters
- $length
integer $length
- $type
string $type
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
string $pattern
- $value
string $value
Returns
boolean
|
protected static
string
|
#
pool( string $type )
Get the character pool for a given type of random string.
Get the character pool for a given type of random string.
Parameters
Returns
string
|