\Ceo\HelpersText

Text processing static class Mostly just helpers

Summary

Methods
Properties
Constants
uuid()
isUuid()
parseSrn()
sluggify()
truncate()
generateToken()
singularize()
Pluralize()
without()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

uuid()

uuid() : string

Generate a (hopefully) unique, time-based UUID

Returns

string —

UUID

isUuid()

isUuid(string  $str) : boolean

Determine if passed string is a UUIDv4

Parameters

string $str

Returns

boolean

parseSrn()

parseSrn(string  $srn) : array

Parse SRN into component parts Return array in the format of <ul> <li>client</li> <li>appid</li> <li>resource</li> <li>uuid</li> <li>extra</li> </ul>

Parameters

string $srn

Returns

array

sluggify()

sluggify(string  $str,   $delim = '-') : string

Generate slugs

Parameters

string $str

string to sluggify

$delim

Returns

string —

slugged string

truncate()

truncate(string  $str, string  $length = 100, string  $ending = '...', boolean  $exact = false, boolean  $considerHtml = true) : string

Trim a string, optionally preserving the sentences.

Parameters

string $str
string $length

Trim length

string $ending

String end

boolean $exact

Make resulting string the exact length

boolean $considerHtml

Consider the HTML output when trimming

Returns

string

generateToken()

generateToken(integer  $length = 10) : string

Generate a relatively random token of a given length.

THIS IS NOT CRYPTOGRAPHICALY SECURE and don't use it for that purpose. You're going to have a bad time.

Based on (https://stackoverflow.com/a/1516430) but improved for randomness and security.

Parameters

integer $length

Returns

string

singularize()

singularize(  $str) : string

Singularize a word

Parameters

$str

Returns

string

Pluralize()

Pluralize(  $str) : string

pluralize a word

Parameters

$str

Returns

string

without()

without(  $str,   $filter = '') : string

Return string with filtered text removed

Parameters

$str
$filter

Returns

string