PHP Класс LaravelBook\Laravel4Powerpack\Str

Показать файл Открыть проект

Открытые методы

Метод Описание
ascii ( string $value ) : string Convert a string to 7-bit ASCII.
camel ( string $value ) : string Convert a value to camel case.
camelCase ( string $value ) : string Convert a value to camel case.
classify ( string $value ) : string Convert a string to an underscored, camel-cased class name.
contains ( string $haystack, string | array $needle ) : boolean Determine if a given string contains a given sub-string.
endsWith ( string $haystack, string $needle ) : boolean Determine if a given string ends with a given needle.
extension ( $fileName ) : string Get a files extension from its path.
finish ( string $value, string $cap ) : string Cap a string with a single instance of a given value.
is ( string $pattern, string $value ) : boolean Determine if a given string matches a given pattern.
length ( $string ) : integer Get the length of a string.
limit ( string $value, integer $limit = 100, string $end = '...' ) : string Limit the number of characters in a string.
limitExact ( string $value, integer $limit = 100, string $end = '...' ) : string Limit the number of chracters in a string including custom ending
lower ( $string ) : string Convert a string to lowercase.
plural ( string $value, integer $count = 2 ) : string Get the plural form of the given word.
quickRandom ( integer $length = 16 ) : string Generate a "random" alpha-numeric string.
random ( integer $length, string $type = 'alnum' ) : string Generate a random alpha or alpha-numeric string.
segments ( string $value ) : array Return the "URI" style segments in a given string.
singular ( string $value ) : string Get the singular form of the given word.
slug ( string $title, string $separator = '-', $keepExtension = false ) : string Generate a URL friendly "slug" from a given string.
snake ( string $value, string $delimiter = '_' ) : string Convert a string to snake case.
startsWith ( string $haystack, string $needle ) : boolean Determine if a string starts with a given needle.
title ( $string ) : string Convert a string to title case (ucwords equivalent).
upper ( $string ) : string Convert a string to uppercase.
upperWords ( string $string ) : string Convert first letter of each word to uppercase.
words ( string $value, integer $words = 100, string $end = '...' ) : string Limit the number of words in a string.
wordwrap ( string $string, $length ) : string Adds a space to a string after a given amount of contiguous, non-whitespace characters.

Защищенные методы

Метод Описание
pool ( string $type ) : string Get the character pool for a given type of random string.

Описание методов

ascii() публичный Метод

This is helpful for converting UTF-8 strings for usage in URLs, etc.
public ascii ( string $value ) : string
$value string
Результат string

camel() публичный статический Метод

Convert a value to camel case.
public static camel ( string $value ) : string
$value string
Результат string

camelCase() публичный Метод

Convert a value to camel case.
public camelCase ( string $value ) : string
$value string
Результат string

classify() публичный Метод

This method is primarily used to format task and controller names. Returns "Task_Name" $class = Str::classify('task_name'); Returns "Taylor_Otwell" $class = Str::classify('taylor otwell')
public classify ( string $value ) : string
$value string
Результат string

contains() публичный Метод

Determine if a given string contains a given sub-string.
public contains ( string $haystack, string | array $needle ) : boolean
$haystack string
$needle string | array
Результат boolean

endsWith() публичный Метод

Determine if a given string ends with a given needle.
public endsWith ( string $haystack, string $needle ) : boolean
$haystack string
$needle string
Результат boolean

extension() публичный Метод

Get a files extension from its path.
public extension ( $fileName ) : string
Результат string $string

finish() публичный Метод

Cap a string with a single instance of a given value.
public finish ( string $value, string $cap ) : string
$value string
$cap string
Результат string

is() публичный Метод

Determine if a given string matches a given pattern.
public is ( string $pattern, string $value ) : boolean
$pattern string
$value string
Результат boolean

length() публичный Метод

Get the length of a string $length = Str::length('Taylor Otwell'); Get the length of a multi-byte string $length = Str::length('Τάχιστη')
public length ( $string ) : integer
Результат integer

limit() публичный Метод

Returns "Tay..." echo Str::limit('Taylor Otwell', 3); Limit the number of characters and append a custom ending echo Str::limit('Taylor Otwell', 3, '---');
public limit ( string $value, integer $limit = 100, string $end = '...' ) : string
$value string
$limit integer
$end string
Результат string

limitExact() публичный Метод

Returns "Taylor..." echo Str::limitExact('Taylor Otwell', 9); Limit the number of characters and append a custom ending echo Str::limitExact('Taylor Otwell', 9, '---');
public limitExact ( string $value, integer $limit = 100, string $end = '...' ) : string
$value string
$limit integer
$end string
Результат string

lower() публичный Метод

Convert a string to lowercase $lower = Str::lower('Taylor Otwell'); Convert a multi-byte string to lowercase $lower = Str::lower('Τάχιστη');
public lower ( $string ) : string
Результат string

plural() публичный Метод

Returns the plural form of "child" $plural = Str::plural('child', 10); Returns the singular form of "octocat" since count is one $plural = Str::plural('octocat', 1);
public plural ( string $value, integer $count = 2 ) : string
$value string
$count integer
Результат string

pool() защищенный Метод

Get the character pool for a given type of random string.
protected pool ( string $type ) : string
$type string
Результат string

quickRandom() публичный статический Метод

Should not be considered sufficient for cryptography, etc.
public static quickRandom ( integer $length = 16 ) : string
$length integer
Результат string

random() публичный Метод

Generate a 40 character random alpha-numeric string echo Str::random(40); Generate a 16 character random alphabetic string echo Str::random(16, 'alpha');
public random ( integer $length, string $type = 'alnum' ) : string
$length integer
$type string
Результат string

segments() публичный Метод

Return the "URI" style segments in a given string.
public segments ( string $value ) : array
$value string
Результат array

singular() публичный Метод

Get the singular form of the given word.
public singular ( string $value ) : string
$value string
Результат string

slug() публичный Метод

Returns "this-is-my-blog-post" $slug = Str::slug('This is my blog post!'); Returns "this_is_my_blog_post" $slug = Str::slug('This is my blog post!', '_');
public slug ( string $title, string $separator = '-', $keepExtension = false ) : string
$title string
$separator string
Результат string

snake() публичный статический Метод

Convert a string to snake case.
public static snake ( string $value, string $delimiter = '_' ) : string
$value string
$delimiter string
Результат string

startsWith() публичный Метод

Determine if a string starts with a given needle.
public startsWith ( string $haystack, string $needle ) : boolean
$haystack string
$needle string
Результат boolean

title() публичный Метод

Convert a string to title case $title = Str::title('taylor otwell'); Convert a multi-byte string to title case $title = Str::title('νωθρού κυνός');
public title ( $string ) : string
Результат string

upper() публичный Метод

Convert a string to uppercase $upper = Str::upper('Taylor Otwell'); Convert a multi-byte string to uppercase $upper = Str::upper('Τάχιστη');
public upper ( $string ) : string
Результат string

upperWords() публичный Метод

Convert first letter of each word to uppercase.
public upperWords ( string $string ) : string
$string string
Результат string

words() публичный Метод

Returns "This is a..." echo Str::words('This is a sentence.', 3); Limit the number of words and append a custom ending echo Str::words('This is a sentence.', 3, '---');
public words ( string $value, integer $words = 100, string $end = '...' ) : string
$value string
$words integer
$end string
Результат string

wordwrap() публичный Метод

Adds a space to a string after a given amount of contiguous, non-whitespace characters.
public wordwrap ( string $string, $length ) : string
$string string
Результат string