class StringHelper (View source)

The StringHelper class.

Constants

INCREMENT_STYLE_DASH

INCREMENT_STYLE_DEFAULT

Methods

static boolean
isEmpty(string $string)

isEmptyString

static boolean
isZero(string $string)

isZero

static string
quote(string $string, array $quote = array('"', '"'))

Quote a string.

static string
backquote(string $string)

Back quote a string.

static string
increment(string $string, string $style = self::INCREMENT_STYLE_DEFAULT, integer $n)

Increments a trailing number in a string.

static string
at(string $string, int $num)

at

static string
collapseWhitespace(string $string)

remove spaces

static boolean
endsWith(string $string, string $target, boolean $caseSensitive = true)

endsWith

static boolean
startsWith(string $string, string $target, boolean $caseSensitive = true)

startsWith

static array
explode(string $separator, string $data, int $number = null, string $callback = 'array_push')

Explode a string and force elements number.

Details

at line line 45
static boolean isEmpty(string $string)

isEmptyString

Parameters

string $string

Return Value

boolean

at line line 64
static boolean isZero(string $string)

isZero

Parameters

string $string

Return Value

boolean

at line line 77
static string quote(string $string, array $quote = array('"', '"'))

Quote a string.

Parameters

string $string The string to quote.
array $quote The quote symbol.

Return Value

string Quoted string.

at line line 96
static string backquote(string $string)

Back quote a string.

Parameters

string $string The string to quote.

Return Value

string Quoted string.

at line line 117
static string increment(string $string, string $style = self::INCREMENT_STYLE_DEFAULT, integer $n)

Increments a trailing number in a string.

Used to easily create distinct labels when copying objects. The method has the following styles:

default: "Label" becomes "Label (2)" dash: "Label" becomes "Label-2"

Parameters

string $string The source string.
string $style The the style (default|dash).
integer $n If supplied, this number is used for the copy, otherwise it is the 'next' number.

Return Value

string The incremented string.

at line line 166
static string at(string $string, int $num)

at

Parameters

string $string
int $num

Return Value

string

at line line 188
static string collapseWhitespace(string $string)

remove spaces

See: http://stackoverflow.com/questions/3760816/remove-new-lines-from-string And: http://stackoverflow.com/questions/9558110/php-remove-line-break-or-cr-lf-with-no-success

Parameters

string $string

Return Value

string

at line line 204
static boolean endsWith(string $string, string $target, boolean $caseSensitive = true)

endsWith

Parameters

string $string
string $target
boolean $caseSensitive

Return Value

boolean

at line line 234
static boolean startsWith(string $string, string $target, boolean $caseSensitive = true)

startsWith

Parameters

string $string
string $target
boolean $caseSensitive

Return Value

boolean

at line line 255
static array explode(string $separator, string $data, int $number = null, string $callback = 'array_push')

Explode a string and force elements number.

Parameters

string $separator
string $data
int $number
string $callback

Return Value

array