final class Filters

internal  
 

Template filters. Uses UTF-8 only.

Methods

static string
stripHtml(FilterInfo $info, $s)

Converts HTML to plain text.

static string
stripTags(FilterInfo $info, $s)

Removes tags from HTML (but remains HTML entites).

static string
strip(FilterInfo $info, string $s)

Replaces all repeated white spaces with a single space.

static string
spacelessHtml(string $s, bool $strip = true)

Replaces all repeated white spaces with a single space.

static string
spacelessHtmlHandler(string $s, int|null $phase = null)

Output buffering handler for spacelessHtml.

static string
spacelessText(string $s)

Replaces all repeated white spaces with a single space.

static string
indent(FilterInfo $info, string $s, int $level = 1, string $chars = "\t")

Indents plain text or HTML the content from the left.

static string
implode(array $arr, string $glue = '')

Join array of text or HTML elements with a string.

static array
explode(string $value, string $separator = '')

Splits a string by a string.

static string
repeat(FilterInfo $info, $s, int $count)

Repeats text.

static string|null
date(string|int|DateTimeInterface|DateInterval|null $time, string|null $format = null)

Date/time formatting.

static string
bytes(float $bytes, int $precision = 2)

Converts to human readable file size.

static string
replace(FilterInfo $info, string|array $subject, string|array $search, string|array|null $replace = null)

Performs a search and replace.

static string
replaceRe(string $subject, string $pattern, string $replacement = '')

Perform a regular expression search and replace.

static string
dataStream(string $data, string|null $type = null)

The data: URI generator.

static Html
breaklines(string|Stringable $s)

No description

static string
substring(string|Stringable $s, int $start, int|null $length = null)

Returns a part of string.

static string
truncate(string|Stringable $s, int $length, string $append = "…")

Truncates string to maximal length.

static string
lower($s)

Convert to lower case.

static string
upper($s)

Convert to upper case.

static string
firstUpper($s)

Convert first character to upper case.

static string
capitalize($s)

Capitalize string.

static int
length(array|Countable|Traversable|string $val)

Returns length of string or iterable.

static string
trim(FilterInfo $info, string $s, string $charlist = " \t\n\r\x00\v ")

Strips whitespace.

static string
padLeft($s, int $length, string $append = ' ')

Pad a string to a certain length with another string.

static string
padRight($s, int $length, string $append = ' ')

Pad a string to a certain length with another string.

static string|array
reverse(string|array|Traversable $val, bool $preserveKeys = false)

Reverses string or array.

static Generator
batch(array|Traversable $list, int $length, $rest = null)

Chunks items by returning an array of arrays with the given number of items.

static array
sort(array $array, Closure|null $callback = null)

Sorts an array.

static int|float
clamp(int|float $value, int|float $min, int|float $max)

Returns value clamped to the inclusive range of min and max.

static string
query(string|array $data)

Generates URL-encoded query string

static bool
divisibleBy(int $value, int $by)

Is divisible by?

static bool
odd(int $value)

Is odd?

static bool
even(int $value)

Is even?

static mixed
first(string|array $value)

Returns the first item from the array or null if array is empty.

static mixed
last(string|array $value)

Returns the last item from the array or null if array is empty.

static string|array
slice(string|array $value, int $start, int|null $length = null, bool $preserveKeys = false)

Extracts a slice of an array or string.

static float
round(float $value, int $precision = 0)

No description

static float
floor(float $value, int $precision = 0)

No description

static float
ceil(float $value, int $precision = 0)

No description

static mixed
random(string|array $values)

Picks random element/char.

Details

at line 29
static string stripHtml(FilterInfo $info, $s)

Converts HTML to plain text.

Parameters

FilterInfo $info
$s

Return Value

string

at line 40
static string stripTags(FilterInfo $info, $s)

Removes tags from HTML (but remains HTML entites).

Parameters

FilterInfo $info
$s

Return Value

string

at line 51
static string strip(FilterInfo $info, string $s)

Replaces all repeated white spaces with a single space.

Parameters

FilterInfo $info
string $s

Return Value

string

at line 62
static string spacelessHtml(string $s, bool $strip = true)

Replaces all repeated white spaces with a single space.

Parameters

string $s
bool $strip

Return Value

string

at line 82
static string spacelessHtmlHandler(string $s, int|null $phase = null)

Output buffering handler for spacelessHtml.

Parameters

string $s
int|null $phase

Return Value

string

at line 107
static string spacelessText(string $s)

Replaces all repeated white spaces with a single space.

Parameters

string $s

Return Value

string

at line 116
static string indent(FilterInfo $info, string $s, int $level = 1, string $chars = "\t")

Indents plain text or HTML the content from the left.

Parameters

FilterInfo $info
string $s
int $level
string $chars

Return Value

string

at line 140
static string implode(array $arr, string $glue = '')

Join array of text or HTML elements with a string.

Parameters

array $arr
string $glue

Return Value

string

at line 149
static array explode(string $value, string $separator = '')

Splits a string by a string.

Parameters

string $value
string $separator

Return Value

array

at line 160
static string repeat(FilterInfo $info, $s, int $count)

Repeats text.

Parameters

FilterInfo $info
$s
int $count

Return Value

string

at line 169
static string|null date(string|int|DateTimeInterface|DateInterval|null $time, string|null $format = null)

Date/time formatting.

Parameters

string|int|DateTimeInterface|DateInterval|null $time
string|null $format

Return Value

string|null

at line 205
static string bytes(float $bytes, int $precision = 2)

Converts to human readable file size.

Parameters

float $bytes
int $precision

Return Value

string

at line 224
static string replace(FilterInfo $info, string|array $subject, string|array $search, string|array|null $replace = null)

Performs a search and replace.

Parameters

FilterInfo $info
string|array $subject
string|array $search
string|array|null $replace

Return Value

string

at line 248
static string replaceRe(string $subject, string $pattern, string $replacement = '')

Perform a regular expression search and replace.

Parameters

string $subject
string $pattern
string $replacement

Return Value

string

at line 262
static string dataStream(string $data, string|null $type = null)

The data: URI generator.

Parameters

string $data
string|null $type

Return Value

string

at line 272
static Html breaklines(string|Stringable $s)

No description

Parameters

string|Stringable $s

Return Value

Html

at line 282
static string substring(string|Stringable $s, int $start, int|null $length = null)

Returns a part of string.

Parameters

string|Stringable $s
int $start
int|null $length

Return Value

string

at line 300
static string truncate(string|Stringable $s, int $length, string $append = "…")

Truncates string to maximal length.

Parameters

string|Stringable $s
int $length
string $append

Return Value

string

at line 323
static string lower($s)

Convert to lower case.

Parameters

$s

Return Value

string

at line 332
static string upper($s)

Convert to upper case.

Parameters

$s

Return Value

string

at line 341
static string firstUpper($s)

Convert first character to upper case.

Parameters

$s

Return Value

string

at line 351
static string capitalize($s)

Capitalize string.

Parameters

$s

Return Value

string

at line 360
static int length(array|Countable|Traversable|string $val)

Returns length of string or iterable.

Parameters

array|Countable|Traversable|string $val

Return Value

int

at line 383
static string trim(FilterInfo $info, string $s, string $charlist = " \t\n\r\x00\v ")

Strips whitespace.

Parameters

FilterInfo $info
string $s
string $charlist

Return Value

string

at line 398
static string padLeft($s, int $length, string $append = ' ')

Pad a string to a certain length with another string.

Parameters

$s
int $length
string $append

Return Value

string

at line 410
static string padRight($s, int $length, string $append = ' ')

Pad a string to a certain length with another string.

Parameters

$s
int $length
string $append

Return Value

string

at line 422
static string|array reverse(string|array|Traversable $val, bool $preserveKeys = false)

Reverses string or array.

Parameters

string|array|Traversable $val
bool $preserveKeys

Return Value

string|array

at line 437
static Generator batch(array|Traversable $list, int $length, $rest = null)

Chunks items by returning an array of arrays with the given number of items.

Parameters

array|Traversable $list
int $length
$rest

Return Value

Generator

at line 465
static array sort(array $array, Closure|null $callback = null)

Sorts an array.

Parameters

array $array
Closure|null $callback

Return Value

array

at line 475
static int|float clamp(int|float $value, int|float $min, int|float $max)

Returns value clamped to the inclusive range of min and max.

Parameters

int|float $value
int|float $min
int|float $max

Return Value

int|float

at line 488
static string query(string|array $data)

Generates URL-encoded query string

Parameters

string|array $data

Return Value

string

at line 499
static bool divisibleBy(int $value, int $by)

Is divisible by?

Parameters

int $value
int $by

Return Value

bool

at line 508
static bool odd(int $value)

Is odd?

Parameters

int $value

Return Value

bool

at line 517
static bool even(int $value)

Is even?

Parameters

int $value

Return Value

bool

at line 526
static mixed first(string|array $value)

Returns the first item from the array or null if array is empty.

Parameters

string|array $value

Return Value

mixed

at line 537
static mixed last(string|array $value)

Returns the last item from the array or null if array is empty.

Parameters

string|array $value

Return Value

mixed

at line 548
static string|array slice(string|array $value, int $start, int|null $length = null, bool $preserveKeys = false)

Extracts a slice of an array or string.

Parameters

string|array $value
int $start
int|null $length
bool $preserveKeys

Return Value

string|array

at line 560
static float round(float $value, int $precision = 0)

No description

Parameters

float $value
int $precision

Return Value

float

at line 566
static float floor(float $value, int $precision = 0)

No description

Parameters

float $value
int $precision

Return Value

float

at line 572
static float ceil(float $value, int $precision = 0)

No description

Parameters

float $value
int $precision

Return Value

float

at line 581
static mixed random(string|array $values)

Picks random element/char.

Parameters

string|array $values

Return Value

mixed