\rex_formatter

String formatter class.

Summary

Methods
Properties
Constants
format()
date()
strftime()
number()
bytes()
sprintf()
nl2br()
truncate()
widont()
version()
url()
email()
custom()
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

format()

format(string  $value, string  $formatType, mixed  $format) : string

Formats a string by the given format type.

Parameters

string $value

Value

string $formatType

Format type (any method name of this class)

mixed $format

For possible values look at the other methods of this class

Throws

\InvalidArgumentException

Returns

string —

date()

date(string|int|null  $value, string  $format = '') : string

Formats a string by `date()`.

Parameters

string|int|null $value

Unix timestamp or datetime string for strtotime

string $format

Default format is d.m.Y

Returns

string —

strftime()

strftime(string|int|null  $value, string  $format = '') : string

Formats a string by `strftime()`.

Parameters

string|int|null $value

Unix timestamp or datetime string for strtotime

string $format

Possible values are format strings like in strftime or "date" or "datetime", default is "date"

Returns

string —

number()

number(string|float  $value, array  $format = []) : string

Formats a string by `number_format()`.

Parameters

string|float $value

Value

array $format

Array with number of decimals, decimals point and thousands separator, default is array(2, ',', ' ')

Returns

string —

bytes()

bytes(string|int  $value, array  $format = []) : string

Formats a string as bytes.

Parameters

string|int $value

Value

array $format

Same as {@link}

Returns

string —

sprintf()

sprintf(string  $value, string  $format = '') : string

Formats a string by `sprintf()`.

Parameters

string $value

Value

string $format

Returns

string —

nl2br()

nl2br(string  $value) : string

Formats a string by `nl2br`.

Parameters

string $value

Value

Returns

string —

truncate()

truncate(string  $value, mixed  $format = []) : string

Truncates a string.

Parameters

string $value

Value

mixed $format

Returns

string —

widont()

widont(string  $value) : string

Avoid widows in a string.

Parameters

string $value

Returns

string —

version()

version(string  $value, string  $format) : string

Formats a version string by `sprintf()`.

Parameters

string $value

Version

string $format

Version format, e.g. "%s.%s"

Returns

string —

url()

url(string  $value, array  $format = []) : string

Formats a string as link.

Parameters

string $value

URL

array $format

Array with link attributes and params

Returns

string —

Link

email()

email(string  $value, array  $format = []) : string

Formats a string as email link.

Parameters

string $value

Email

array $format

Array with link attributes and params

Returns

string —

Email link

custom()

custom(string  $value, callable|array  $format) : string

Formats a string by a custom callable.

Parameters

string $value

Value

callable|array $format

A callable or an array of a callable and additional params

Throws

\rex_exception

Returns

string —