PHP Class rex_formatter, redaxo

Datei anzeigen Open project: redaxo/redaxo Class Usage Examples

Public Methods

Method Description
bytes ( string $value, array $format = [] ) : string Formats a string as bytes.
custom ( string $value, callable | array $format ) : string Formats a string by a custom callable.
date ( string $value, string $format = '' ) : string Formats a string by date().
email ( string $value, array $format = [] ) : string Formats a string as email link.
format ( string $value, string $formatType, mixed $format ) : string Formats a string by the given format type.
nl2br ( string $value ) : string Formats a string by nl2br.
number ( string $value, array $format = [] ) : string Formats a string by number_format().
sprintf ( string $value, string $format = '' ) : string Formats a string by sprintf().
strftime ( string $value, string $format = '' ) : string Formats a string by strftime().
truncate ( string $value, array $format = [] ) : string Truncates a string.
url ( string $value, array $format = [] ) : string Formats a string as link.
version ( string $value, string $format ) : string Formats a version string by sprintf().
widont ( string $value ) : string Avoid widows in a string.

Private Methods

Method Description
__construct ( ) It's not allowed to create instances of this class.
getTimestamp ( $value )

Method Details

bytes() public static method

Formats a string as bytes.
public static bytes ( string $value, array $format = [] ) : string
$value string Value
$format array Same as {@link rex_formatter::number()}
return string

custom() public static method

Formats a string by a custom callable.
public static custom ( string $value, callable | array $format ) : string
$value string Value
$format callable | array A callable or an array of a callable and additional params
return string

date() public static method

Formats a string by date().
See also: http://www.php.net/manual/en/function.date.php
public static date ( string $value, string $format = '' ) : string
$value string Unix timestamp or datetime string for `strtotime`
$format string Default format is `d.m.Y`
return string

email() public static method

Formats a string as email link.
public static email ( string $value, array $format = [] ) : string
$value string Email
$format array Array with link attributes and params
return string Email link

format() public static method

Formats a string by the given format type.
public static format ( string $value, string $formatType, mixed $format ) : string
$value string Value
$formatType string Format type (any method name of this class)
$format mixed For possible values look at the other methods of this class
return string

nl2br() public static method

Formats a string by nl2br.
See also: http://www.php.net/manual/en/function.nl2br.php
public static nl2br ( string $value ) : string
$value string Value
return string

number() public static method

Formats a string by number_format().
See also: http://www.php.net/manual/en/function.number-format.php
public static number ( string $value, array $format = [] ) : string
$value string Value
$format array Array with number of decimals, decimals point and thousands separator, default is `array(2, ',', ' ')`
return string

sprintf() public static method

Formats a string by sprintf().
See also: http://www.php.net/manual/en/function.sprintf.php
public static sprintf ( string $value, string $format = '' ) : string
$value string Value
$format string
return string

strftime() public static method

Formats a string by strftime().
See also: http://www.php.net/manual/en/function.strftime.php
public static strftime ( string $value, string $format = '' ) : string
$value string Unix timestamp or datetime string for `strtotime`
$format string Possible values are format strings like in `strftime` or "date" or "datetime", default is "date"
return string

truncate() public static method

Truncates a string.
public static truncate ( string $value, array $format = [] ) : string
$value string Value
$format array Default format is `array('length' => 80, 'etc' => '...', 'break_words' => false)`
return string

url() public static method

Formats a string as link.
public static url ( string $value, array $format = [] ) : string
$value string URL
$format array Array with link attributes and params
return string Link

version() public static method

Formats a version string by sprintf().
See also: http://www.php.net/manual/en/function.sprintf.php
public static version ( string $value, string $format ) : string
$value string Version
$format string Version format, e.g. "%s.%s"
return string

widont() public static method

Avoid widows in a string.
public static widont ( string $value ) : string
$value string
return string