StringUtil
in package
Class StringUtil.
Use Utils service instead
Table of Contents
Constants
- CAPITAL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- CAPITAL_LETTERS_NONAMBIGUOUS = 'ABCDEFGHJKLMNPQRSTUVWX'
- NUMBERS = '0123456789'
- NUMBERS_NONAMBIGUOUS = '23456789'
- SMALL_LETTERS = 'abcdefghijklmnopqrstuvwxyz'
- SMALL_LETTERS_NONAMBIGUOUS = 'abcdefghjkmnpqrstuvwx'
Properties
- $framework : ContaoFrameworkInterface
- $utils : Utils
Methods
- __construct() : mixed
- camelCaseToDashed() : string
- Convert a camel case string to a dashed string.
- camelCaseToSnake() : string
- Convert a camel case string to a snake cased string.
- convertToInlineCss() : string
- Convert css into inline styles.
- convertXmlToArray() : mixed
- endsWith() : bool
- Check for the occurrence at the end of the string.
- ensureLineBreaks() : string
- Ensure line breaks for several languages.
- html2Text() : string
- Converts html to text.
- lowerCase() : string
- Convenience method for lower casing in a save callback.
- pregReplaceLast() : mixed|string
- random() : mixed
- randomChar() : mixed
- randomLetter() : mixed
- randomNumber() : mixed
- removeLeadingAndTrailingSlash() : string
- removeLeadingString() : mixed
- removeTrailingString() : mixed
- replaceInsertTags() : string
- Replace insert tags with their values.
- replaceUnicodeEmojisByHtml() : array<string|int, mixed>|string|array<string|int, string>|null
- restoreBasicEntities() : string
- Restore basic entities.
- startsWith() : bool
- Check for the occurrence at the start of the string.
- truncateHtml() : string
- Truncates a given string respecting html element.
Constants
CAPITAL_LETTERS
public
mixed
CAPITAL_LETTERS
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
CAPITAL_LETTERS_NONAMBIGUOUS
public
mixed
CAPITAL_LETTERS_NONAMBIGUOUS
= 'ABCDEFGHJKLMNPQRSTUVWX'
NUMBERS
public
mixed
NUMBERS
= '0123456789'
NUMBERS_NONAMBIGUOUS
public
mixed
NUMBERS_NONAMBIGUOUS
= '23456789'
SMALL_LETTERS
public
mixed
SMALL_LETTERS
= 'abcdefghijklmnopqrstuvwxyz'
SMALL_LETTERS_NONAMBIGUOUS
public
mixed
SMALL_LETTERS_NONAMBIGUOUS
= 'abcdefghjkmnpqrstuvwx'
Properties
$framework
protected
ContaoFrameworkInterface
$framework
$utils
protected
Utils
$utils
Methods
__construct()
public
__construct(ContaoFrameworkInterface $framework, Utils $utils) : mixed
Parameters
- $framework : ContaoFrameworkInterface
- $utils : Utils
camelCaseToDashed()
Convert a camel case string to a dashed string.
public
camelCaseToDashed(string $value) : string
Use utils service instead
Example: MyPrettyClass to my-pretty-class
Parameters
- $value : string
Tags
Return values
stringcamelCaseToSnake()
Convert a camel case string to a snake cased string.
public
camelCaseToSnake(string $value) : string
Use utils service instead
Example: MyPrettyClass to my_pretty_class
Parameters
- $value : string
Tags
Return values
stringconvertToInlineCss()
Convert css into inline styles.
public
convertToInlineCss(string $text[, array<string|int, mixed> $cssText = null ]) : string
Use CssInliner-Library directly in your code. We recommend tijsverkoyen/css-to-inline-styles (https://github.com/tijsverkoyen/CssToInlineStyles)
Parameters
- $text : string
- $cssText : array<string|int, mixed> = null
-
the css as text (no paths allowed atm)
Tags
Return values
stringconvertXmlToArray()
public
convertXmlToArray(string $xmlData) : mixed
Use utils service instead
Parameters
- $xmlData : string
Tags
endsWith()
Check for the occurrence at the end of the string.
public
endsWith(string $haystack, string $needle) : bool
Use utils service instead
Parameters
- $haystack : string
-
The string to search in
- $needle : string
-
The needle
Tags
Return values
boolensureLineBreaks()
Ensure line breaks for several languages.
public
ensureLineBreaks(string $buffer[, string $language = 'en' ]) : string
use locale util of utils service instead
Parameters
- $buffer : string
- $language : string = 'en'
Return values
stringhtml2Text()
Converts html to text.
public
html2Text(string $html[, array<string|int, mixed> $options = [] ]) : string
Use html2text-library direct in your code, we recommend html2text/html2text (https://github.com/mtibben/html2text)
Parameters
- $html : string
- $options : array<string|int, mixed> = []
Tags
Return values
stringlowerCase()
Convenience method for lower casing in a save callback.
public
lowerCase(mixed $value, DataContainer $objDc) : string
Deprecated in favor of custom callback that could be used with contao service callbacks
Parameters
- $value : mixed
- $objDc : DataContainer
Tags
Return values
stringpregReplaceLast()
public
pregReplaceLast(string $regExp, string $subject) : mixed|string
Use utils service instead
Parameters
- $regExp : string
- $subject : string
Tags
Return values
mixed|stringrandom()
public
random(string $charList) : mixed
Use utils service instead
Parameters
- $charList : string
Tags
randomChar()
public
randomChar([bool $includeAmbiguousChars = false ]) : mixed
Use utils service instead
Parameters
- $includeAmbiguousChars : bool = false
Tags
randomLetter()
public
randomLetter([bool $includeAmbiguousChars = false ]) : mixed
Use utils service instead
Parameters
- $includeAmbiguousChars : bool = false
Tags
randomNumber()
public
randomNumber([bool $includeAmbiguousChars = false ]) : mixed
Use utils service instead
Parameters
- $includeAmbiguousChars : bool = false
Tags
removeLeadingAndTrailingSlash()
public
removeLeadingAndTrailingSlash(string $string) : string
Use trim($string, "/") instead
Parameters
- $string : string
Tags
Return values
stringremoveLeadingString()
public
removeLeadingString(string $string, string $subject) : mixed
Use utils service instead
Parameters
- $string : string
- $subject : string
Tags
removeTrailingString()
public
removeTrailingString(string $string, string $subject) : mixed
Use utils service instead
Parameters
- $string : string
- $subject : string
Tags
replaceInsertTags()
Replace insert tags with their values.
public
replaceInsertTags(string $buffer[, bool $cache = true ]) : string
Use Controller::replaceInsertTags as adapter
Parameters
- $buffer : string
-
The text with the tags to be replaced
- $cache : bool = true
-
If false, non-cacheable tags will be replaced
Tags
Return values
string —The text with the replaced tags
replaceUnicodeEmojisByHtml()
public
replaceUnicodeEmojisByHtml(string|null $text) : array<string|int, mixed>|string|array<string|int, string>|null
Will be removed in version 3.0. Use elvanto/litemoji (https://github.com/elvanto/litemoji) instead.
Parameters
- $text : string|null
Tags
Return values
array<string|int, mixed>|string|array<string|int, string>|nullrestoreBasicEntities()
Restore basic entities.
public
restoreBasicEntities(string $string) : string
use \Contao\StringUtil::restoreBasicEntities() instead
Parameters
- $string : string
-
The string with the tags to be replaced
Tags
Return values
string —The string with the original entities
startsWith()
Check for the occurrence at the start of the string.
public
startsWith(mixed $haystack, mixed $needle) : bool
Use utils service instead
Parameters
- $haystack : mixed
-
string The string to search in
- $needle : mixed
-
string The needle
Tags
Return values
booltruncateHtml()
Truncates a given string respecting html element.
public
truncateHtml(string $text[, int $length = 100 ][, string $ending = ' …' ][, bool $exact = false ][, bool $considerHtml = true ]) : string
Use utils service instead
Parameters
- $text : string
- $length : int = 100
- $ending : string = ' …'
- $exact : bool = false
- $considerHtml : bool = true