PHP Class QString, qcodo

Show file Open project: qcodo/qcodo Class Usage Examples

Public Methods

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

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

FirstCharacter() final public static method

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
return string the first character, or null

GetByteSize() public static method

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

IsContainsUtf8() public static method

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
return boolean whether or not the string contains any UTF-8 characters

IsLengthBeetween() public static method

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

IsStartsWith() final public static method

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

LastCharacter() final public static method

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
return string the last character, or null

ObfuscateEmail() public static method

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
return string the HTML of the obfuscated Email address

QuotedPrintableEncode() public static method

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

StringPosition() public static method

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
return mixed the position number OR false if not found

StringReversePosition() public static method

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
return mixed the position number OR false if not found

Truncate() final public static method

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
return string the full string or the truncated string with eplise

XmlEscape() final public static method

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
return string the XML Node-safe String

__construct() final public method

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