PHP Class Bolt\Helpers\Html

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

Méthodes publiques

Méthode Description
addScheme ( string $url, string $scheme = 'http://' ) : string Add 'http://' to a link, if it has no protocol already.
decorateTT ( string $str ) : string Transforms plain text to HTML. Plot twist: text between backticks (`) is wrapped in a element.
isURL ( string $str ) : boolean Check if a given string looks like it could be a URL, with or without the protocol.
providerLink ( array $providedby ) : string Create 'provider' link, as used in the footer, to link to either an email address or website URL.
trimText ( string $str, integer $desiredLength, boolean $hellip = true, integer $cutOffCap = 10 ) : string Trim text to a given length.

Method Details

addScheme() public static méthode

Add 'http://' to a link, if it has no protocol already.
public static addScheme ( string $url, string $scheme = 'http://' ) : string
$url string
$scheme string
Résultat string

decorateTT() public static méthode

Transforms plain text to HTML. Plot twist: text between backticks (`) is wrapped in a element.
public static decorateTT ( string $str ) : string
$str string Input string. Treated as plain text.
Résultat string The resulting HTML

isURL() public static méthode

Check if a given string looks like it could be a URL, with or without the protocol.
See also: https://mathiasbynens.be/demo/url-regex
public static isURL ( string $str ) : boolean
$str string
Résultat boolean

trimText() public static méthode

Trim text to a given length.
public static trimText ( string $str, integer $desiredLength, boolean $hellip = true, integer $cutOffCap = 10 ) : string
$str string String to trim
$desiredLength integer Target string length
$hellip boolean Add dots when the string is too long
$cutOffCap integer Maximum difference between string length when removing words
Résultat string Trimmed string