PHP Class QString, qcodo

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

Méthodes publiques

Méthode Description
ConvertToCamelCase ( string $strString ) : string Given an underscore_separated_string, this will convert the string to CamelCaseNotation. Note that this will ignore any casing in the underscore separated string.
FirstCharacter ( string $strString ) : string Returns the first character of a given string, or null if the given string is null.
GetByteSize ( integer $intBytes, $intNumberOfTenths = 1 ) : string Given an integer that represents a byte size, this will return a string displaying the value in bytes, KB, MB, GB, TB or PB
IsContainsUtf8 ( string $strString ) : boolean Returns whether or not the given string contains any UTF-8 encoded characters.
IsLengthBeetween ( string $strString, integer $intMinimumLength, integer $intMaximumLength ) : boolean Checks if text length is between given bounds
IsStartsWith ( $strString, $strStartsWith ) : boolean Returns whether or not the given string starts with another string
LastCharacter ( string $strString ) : string Returns the last character of a given string, or null if the given string is null.
ObfuscateEmail ( string $strEmail ) : string Obfuscates an email so that it can be outputted as HTML to the page.
QuotedPrintableEncode ( string $strString ) : string Encodes a given 8-bit string into a quoted-printable string,
StringPosition ( string $strHaystack, string &$strNeedle, integer $intOffset = null ) : mixed Similar to strpos(haystack, needle, [offset]) except "needle" can be a regular expression as well.
StringReversePosition ( string $strHaystack, string &$strNeedle, integer $intOffset = null ) : mixed A better version of strrpos which also allows for the use of RegExp-based matching
Truncate ( $strText, integer $intMaxLength, bololean $blnHtmlEntities = true ) : string Truncates the string to a given length, adding elipses (if needed).
XmlEscape ( string $strString ) : string Escapes the string so that it can be safely used in as an Xml Node (basically, adding CDATA if needed)
__construct ( ) : void This faux constructor method throws a caller exception.

Method Details

ConvertToCamelCase() public static méthode

Given an underscore_separated_string, this will convert the string to CamelCaseNotation. Note that this will ignore any casing in the underscore separated string.
public static ConvertToCamelCase ( string $strString ) : string
$strString string
Résultat string

FirstCharacter() final public static méthode

Returns the first character of a given string, or null if the given string is null.
final public static FirstCharacter ( string $strString ) : string
$strString string
Résultat string the first character, or null

GetByteSize() public static méthode

Given an integer that represents a byte size, this will return a string displaying the value in bytes, KB, MB, GB, TB or PB
public static GetByteSize ( integer $intBytes, $intNumberOfTenths = 1 ) : string
$intBytes integer
Résultat string

IsContainsUtf8() public static méthode

Uses regexp pattern as originally defined from http://w3.org/International/questions/qa-forms-utf-8.html and modified by [email protected] for efficiency.
public static IsContainsUtf8 ( string $strString ) : boolean
$strString string
Résultat boolean whether or not the string contains any UTF-8 characters

IsLengthBeetween() public static méthode

Checks if text length is between given bounds
public static IsLengthBeetween ( string $strString, integer $intMinimumLength, integer $intMaximumLength ) : boolean
$strString string Text to be checked
$intMinimumLength integer Minimum acceptable length
$intMaximumLength integer Maximum acceptable length
Résultat boolean

IsStartsWith() final public static méthode

Returns whether or not the given string starts with another string
final public static IsStartsWith ( $strString, $strStartsWith ) : boolean
$strString
$strStartsWith
Résultat boolean

LastCharacter() final public static méthode

Returns the last character of a given string, or null if the given string is null.
final public static LastCharacter ( string $strString ) : string
$strString string
Résultat string the last character, or null

ObfuscateEmail() public static méthode

Obfuscates an email so that it can be outputted as HTML to the page.
public static ObfuscateEmail ( string $strEmail ) : string
$strEmail string the email address to obfuscate
Résultat string the HTML of the obfuscated Email address

QuotedPrintableEncode() public static méthode

Encodes a given 8-bit string into a quoted-printable string,
public static QuotedPrintableEncode ( string $strString ) : string
$strString string the string to encode
Résultat string the encoded string

StringPosition() public static méthode

Will only work if both the first and last character of "needle" is "/", signifying a regexp-based search. NOTE: If a regexp was used, needle WILL be modified to reflect the actual string literal found/used in the search.
public static StringPosition ( string $strHaystack, string &$strNeedle, integer $intOffset = null ) : mixed
$strHaystack string the contents to search through
$strNeedle string the search term itself (either a literal string OR a regexp value)
$intOffset integer optional offset value
Résultat mixed the position number OR false if not found

StringReversePosition() public static méthode

A better version of strrpos which also allows for the use of RegExp-based matching
public static StringReversePosition ( string $strHaystack, string &$strNeedle, integer $intOffset = null ) : mixed
$strHaystack string the text content to search through
$strNeedle string either a plain-text item or a regexp pattern item to search for - if regexp used, this will update as the actual string of the content found
$intOffset integer optional position offset
Résultat mixed the position number OR false if not found

Truncate() final public static méthode

Truncates the string to a given length, adding elipses (if needed).
final public static Truncate ( $strText, integer $intMaxLength, bololean $blnHtmlEntities = true ) : string
$intMaxLength integer the maximum possible length of the string to return (including length of the elipse)
$blnHtmlEntities bololean whether or not to escape the text with htmlentities first
Résultat string the full string or the truncated string with eplise

XmlEscape() final public static méthode

Escapes the string so that it can be safely used in as an Xml Node (basically, adding CDATA if needed)
final public static XmlEscape ( string $strString ) : string
$strString string string to escape
Résultat string the XML Node-safe String

__construct() final public méthode

The String object should never be instantiated, and this constructor override simply guarantees it.
final public __construct ( ) : void
Résultat void