class Text

text helpers

Constants

LOWER_CASE

UPPER_CASE

FIRST_LETTER_UPPER

Methods

static string
replaceChars(string $text)

Replace umlauts chars

static string
cleanText(string|null $text)

Clean Text

static string
pad(string $input, int $length, string $char = ' ', bool $htmlSafe = true)

Pad a string to a certain length with another string (both side)

static string
padLeft(string $input, int $length, string $char = ' ', bool $htmlSafe = true)

Pad left a string to a certain length with another string

static string
padRight(string $input, int $length, string $char = ' ', bool $htmlSafe = true)

Pad right a string to a certain length with another string

static string
mask(string $text, int $len = 5, string $maskChar = '*')

Mask text

static string
ucFirstUtf(string $text)

Upper case first letter for Utf8

static string
sliceText(string $text, int $maxLength = 30)

Slice text

static array
tokenize(string|array $text, mixed ...$options)

Tokenize text split to words

static string
transformWord(string $word, mixed ...$options)

Transform word ( removes all not a-z chars )

static string
removeSpecialChars(string $text, bool $removeNumbers = false)

Remove special chars and numbers from text

static string
convertToTitleCase(string $text)

Convert to title (pascal) case

static string
render(string $text, array $vars = [])

Replace all code {{ var }} in text with var value

static array
renderMultiple(array $items, array $vars = [])

Render multiple text items

static string
createToken(int $length = 22)

Ceate random token

static string
random(int $length = 10, string|null $keyspace = null)

Create random text

static string
randomString(int $length = 10)

Create randowm string

Details

at line 27
static string replaceChars(string $text)

Replace umlauts chars

Parameters

string $text

Return Value

string

at line 59
static string cleanText(string|null $text)

Clean Text

Parameters

string|null $text

Return Value

string

at line 73
static string pad(string $input, int $length, string $char = ' ', bool $htmlSafe = true)

Pad a string to a certain length with another string (both side)

Parameters

string $input
int $length
string $char
bool $htmlSafe

Return Value

string

at line 89
static string padLeft(string $input, int $length, string $char = ' ', bool $htmlSafe = true)

Pad left a string to a certain length with another string

Parameters

string $input
int $length
string $char
bool $htmlSafe

Return Value

string

at line 105
static string padRight(string $input, int $length, string $char = ' ', bool $htmlSafe = true)

Pad right a string to a certain length with another string

Parameters

string $input
int $length
string $char
bool $htmlSafe

Return Value

string

at line 120
static string mask(string $text, int $len = 5, string $maskChar = '*')

Mask text

Parameters

string $text
int $len
string $maskChar

Return Value

string

at line 131
static string ucFirstUtf(string $text)

Upper case first letter for Utf8

Parameters

string $text

Return Value

string

at line 143
static string sliceText(string $text, int $maxLength = 30)

Slice text

Parameters

string $text
int $maxLength

Return Value

string

at line 161
static array tokenize(string|array $text, mixed ...$options)

Tokenize text split to words

Parameters

string|array $text
mixed ...$options

Return Value

array

at line 197
static string transformWord(string $word, mixed ...$options)

Transform word ( removes all not a-z chars )

Parameters

string $word
mixed ...$options 1 - case

Return Value

string

at line 229
static string removeSpecialChars(string $text, bool $removeNumbers = false)

Remove special chars and numbers from text

Parameters

string $text
bool $removeNumbers

Return Value

string

at line 240
static string convertToTitleCase(string $text)

Convert to title (pascal) case

Parameters

string $text

Return Value

string

at line 258
static string render(string $text, array $vars = [])

Replace all code {{ var }} in text with var value

Parameters

string $text
array $vars

Return Value

string

at line 275
static array renderMultiple(array $items, array $vars = [])

Render multiple text items

Parameters

array $items
array $vars

Return Value

array

at line 292
static string createToken(int $length = 22)

Ceate random token

Parameters

int $length

Return Value

string

at line 311
static string random(int $length = 10, string|null $keyspace = null)

Create random text

Parameters

int $length
string|null $keyspace

Return Value

string

at line 326
static string randomString(int $length = 10)

Create randowm string

Parameters

int $length

Return Value

string