-
Notifications
You must be signed in to change notification settings - Fork 1
ConvertHelper
Mistralys edited this page Oct 29, 2019
·
4 revisions
As the name implies, this class is used mainly for converting data of all kinds. However, it also has a number of useful utility functions.
The ConvertHelper class is entirely static. It does not require any configuration.
- string2array: Splits a string into a characters array, unicode safe.
- string2attributeJS: Escapes a string to be inserted into a JavaScript statement in an HTML tag.
- string2bool: Converts a boolean string representation to a boolean value (yes/no/true/false...).
- string2bytes: Counts the amount of bytes a string uses, unicode safe.
- string2hash: Converts a string to a hash string (MD5).
- string2shortHash: Converts a string to a shorter hash (CRC32).
- string2utf8: Converts any string to valid UTF-8.
- tabs2spaces: Converts all tabs to spaces in a string.
- text_cut: Cuts a string at the specified length.-
- wordwrap: Word wraps a string to a specific line length.
- array2attributeString: Converts an associative array to an HTML attribute string.
- array2styleString: Converts an associative array to a CSS style string.
- implodeWithAnd: Implodes a list of strings with commas and "and" at the end, localized.
- date2dayName: Converts a DateTime object to a localized day name.
- date2listLabel: Converts a DateTime object to a human readable string.
- date2timestamp: Converts a DateTime object to a timestamp.
- duration2string: Converts a timespan between two dates into a human readable string.
- getDayNames: Returns a list of localized day names (long or short).
- getDayNamesInvariant: Retrieves a list of english day names.
- interval2string: Converts a DateInterval object to a human readable string.
- interval2total: Calculates the total amount of days, hours, minutes or seconds in a DateInterval.
- month2string: Converts a month number to a localized month name.
- time2string: Converts seconds into a human readable duration string.
- timestamp2date: Converts a timestamp to a DateTime object.
- areNumbersEqual: Checks if two numbers are equal.
- areStringsEqual: Checks if two strings are equal.
- areVariablesEqual: Checks if two variables are equal.
- isBoolean: Checks if the value can be considered boolean (string, numeric, etc).
- isStringASCII: Checks if the string is ASCII, i.e. contains no special or unicode characters.
- isStringHTML: Checks if the string contains HTML code.
- highlight_php: Highlight a PHP string.
- highlight_sql: Highlight an SQL string.
- highlight_url: Highlight the logical parts of an URL.
- highlight_xml: Highlight an XML string.
- callback2string: Converts a callable value to a human readable string.
- bytes2string: Converts bytes to a human readable value.
-
exception2info: Alias for
throwableInfo
. - throwable2info: Converts a throwable object to a class with a handy API to retrieve info about it.
New here?
Have a look at the overview for a list of all helper classes available in the package.
Table of contents
Find the current page in the collapsible "Pages" list above, and expand the page, to view a table of contents.