PHP Class Bolt\Twig\Handler\TextHandler

Show file Open project: bolt/bolt Class Usage Examples

Public Methods

Method Description
__construct ( Silex\Application $app )
jsonDecode ( string $string ) : array JSON decodes a variable. Twig has a built-in json_encode filter, but no built-in function to JSON decode a string. This functionality remedies that.
localeDateTime ( string | DateTime $dateTime, string $format = '%B %e, %Y %H:%M' ) : string Returns the date time in a particular format. Takes the locale into account.
pregReplace ( string $str, string $pattern, string $replacement = '', integer $limit ) : string Perform a regular expression search and replace on the given string.
safeString ( string $str, boolean $strict = false, string $extrachars = '' ) : string Return a 'safe string' version of a given string.
slug ( string $str ) : string Return the 'sluggified' version of a string.
testJson ( string $string ) : boolean Test whether a passed string contains valid JSON.

Method Details

__construct() public method

public __construct ( Silex\Application $app )
$app Silex\Application

jsonDecode() public method

JSON decodes a variable. Twig has a built-in json_encode filter, but no built-in function to JSON decode a string. This functionality remedies that.
public jsonDecode ( string $string ) : array
$string string The string to decode.
return array The JSON decoded array

localeDateTime() public method

Returns the date time in a particular format. Takes the locale into account.
public localeDateTime ( string | DateTime $dateTime, string $format = '%B %e, %Y %H:%M' ) : string
$dateTime string | DateTime
$format string
return string Formatted date and time

pregReplace() public method

Perform a regular expression search and replace on the given string.
public pregReplace ( string $str, string $pattern, string $replacement = '', integer $limit ) : string
$str string
$pattern string
$replacement string
$limit integer
return string Same string where first character is in upper case

safeString() public method

Return a 'safe string' version of a given string.
See also: function Bolt\Library::safeString()
public safeString ( string $str, boolean $strict = false, string $extrachars = '' ) : string
$str string
$strict boolean
$extrachars string
return string

slug() public method

Return the 'sluggified' version of a string.
public slug ( string $str ) : string
$str string input value
return string Slug safe version of the string

testJson() public method

Test whether a passed string contains valid JSON.
public testJson ( string $string ) : boolean
$string string The string to test.
return boolean