PHP Class Bolt\Helpers\Str

ファイルを表示 Open project: bolt/bolt Class Usage Examples

Public Methods

Method Description
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.

Method Details

endsWith() public static method

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
return boolean

makeSafe() public static method

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
return string

replaceFirst() public static method

Replace the first occurence of a string only. Behaves like str_replace, but replaces _only_ the _first_ occurence.
See also: http://stackoverflow.com/a/2606638
public static replaceFirst ( string $search, string $replace, string $subject ) : string
$search string
$replace string
$subject string
return string

replaceLast() public static method

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
return string

shyphenate() public static method

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
return string