PHP Class Bolt\Helpers\Str

Afficher le fichier Open project: bolt/bolt Class Usage Examples

Méthodes publiques

Méthode 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 méthode

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
Résultat boolean

makeSafe() public static méthode

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
Résultat string

replaceFirst() public static méthode

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
Résultat string

replaceLast() public static méthode

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
Résultat string

shyphenate() public static méthode

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
Résultat string