PHP Класс Bolt\Helpers\Str

Показать файл Открыть проект Примеры использования класса

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

Метод Описание
endsWith ( string $subject, string $search, boolean $caseSensitive = true ) : boolean Returns whether the subjects ends with the search string.
makeSafe ( string $str, boolean $strict = false, string $extrachars = '' ) : string Returns a "safe" version of the given string - basically only US-ASCII and numbers. Needed because filenames and titles and such, can't use all characters.
replaceFirst ( string $search, string $replace, string $subject ) : string Replace the first occurence of a string only. Behaves like str_replace, but replaces _only_ the _first_ occurence.
replaceLast ( string $search, string $replace, string $subject, boolean $caseSensitive = true ) : string Replace only the last occurrence of the $search text on the $subject.
shyphenate ( string $str ) : string Add 'soft hyphens' ­ to a string, so that it won't break layout in HTML when using strings without spaces or dashes. Only breaks in long (> 19 chars) words.

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

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

Returns whether the subjects ends with the search string.
public static endsWith ( string $subject, string $search, boolean $caseSensitive = true ) : boolean
$subject string
$search string
$caseSensitive boolean
Результат boolean

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

Returns a "safe" version of the given string - basically only US-ASCII and numbers. Needed because filenames and titles and such, can't use all characters.
public static makeSafe ( string $str, boolean $strict = false, string $extrachars = '' ) : string
$str string
$strict boolean
$extrachars string
Результат string

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

Replace the first occurence of a string only. Behaves like str_replace, but replaces _only_ the _first_ occurence.
См. также: http://stackoverflow.com/a/2606638
public static replaceFirst ( string $search, string $replace, string $subject ) : string
$search string
$replace string
$subject string
Результат string

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

Replace only the last occurrence of the $search text on the $subject.
public static replaceLast ( string $search, string $replace, string $subject, boolean $caseSensitive = true ) : string
$search string
$replace string
$subject string
$caseSensitive boolean
Результат string

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

Add 'soft hyphens' ­ to a string, so that it won't break layout in HTML when using strings without spaces or dashes. Only breaks in long (> 19 chars) words.
public static shyphenate ( string $str ) : string
$str string
Результат string