PHP Class rex_formatter, redaxo

Afficher le fichier Open project: redaxo/redaxo Class Usage Examples

Méthodes publiques

Méthode 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

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

Method Details

bytes() public static méthode

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

custom() public static méthode

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
Résultat string

date() public static méthode

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`
Résultat string

email() public static méthode

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
Résultat string Email link

format() public static méthode

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
Résultat string

nl2br() public static méthode

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
Résultat string

number() public static méthode

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, ',', ' ')`
Résultat string

sprintf() public static méthode

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
Résultat string

strftime() public static méthode

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"
Résultat string

truncate() public static méthode

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)`
Résultat string

url() public static méthode

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

version() public static méthode

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"
Résultat string

widont() public static méthode

Avoid widows in a string.
public static widont ( string $value ) : string
$value string
Résultat string