class Text

Text processing static class Mostly just helpers

Methods

static string
uuid()

Generate a (hopefully) unique, time-based UUID

static boolean
isUuid(string $str)

Determine if passed string is a UUIDv4

static array
parseSrn(string $srn)

Parse SRN into component parts Return array in the format of

  • client
  • appid
  • resource
  • uuid
  • extra

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

Generate slugs

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

Trim a string, optionally preserving the sentences.

static string
generateToken(int $length = 10)

Generate a relatively random token of a given length.

static string
singularize(string $str)

Singularize a word

static string
Pluralize(string $str)

pluralize a word

Details

at line 19
static string uuid()

Generate a (hopefully) unique, time-based UUID

Return Value

string UUID

at line 30
static boolean isUuid(string $str)

Determine if passed string is a UUIDv4

Parameters

string $str

Return Value

boolean

at line 49
static array parseSrn(string $srn)

Parse SRN into component parts Return array in the format of

  • client
  • appid
  • resource
  • uuid
  • extra

Parameters

string $srn

Return Value

array

at line 85
static string sluggify($str, $delim = '-')

Generate slugs

Parameters

$str
$delim

Return Value

string slugged string

See also

\Phalcon\Utils\Slug in the incubator

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.

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

Return Value

string

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.

Parameters

int $length

Return Value

string

at line 155
static string singularize(string $str)

Singularize a word

Parameters

string $str

Return Value

string

at line 165
static string Pluralize(string $str)

pluralize a word

Parameters

string $str

Return Value

string