Text
class Text
Text processing static class Mostly just helpers
Methods
Generate a (hopefully) unique, time-based UUID
Determine if passed string is a UUIDv4
Parse SRN into component parts Return array in the format of
- client
- appid
- resource
- uuid
- extra
Generate slugs
Trim a string, optionally preserving the sentences.
Generate a relatively random token of a given length.
Singularize a word
pluralize a word
Details
at line 19
static string
uuid()
Generate a (hopefully) unique, time-based UUID
at line 30
static boolean
isUuid(string $str)
Determine if passed string is a UUIDv4
at line 49
static array
parseSrn(string $srn)
Parse SRN into component parts Return array in the format of
- client
- appid
- resource
- uuid
- extra
at line 85
static string
sluggify($str, $delim = '-')
Generate slugs
at line 107
static string
truncate(string $str, string $length = 100, string $ending = '...', boolean $exact = false, boolean $considerHtml = true)
Trim a string, optionally preserving the sentences.
at line 124
static string
generateToken(int $length = 10)
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.
at line 155
static string
singularize(string $str)
Singularize a word
at line 165
static string
Pluralize(string $str)
pluralize a word