PHP Class Bolt\Helpers\Html

Show file Open project: bolt/bolt Class Usage Examples

Public Methods

Method 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 method

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

decorateTT() public static method

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.
return string The resulting HTML

isURL() public static method

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
return boolean

trimText() public static method

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
return string Trimmed string