Class String

Description

String Class

Just a simple collection of static functions to accomplish some of the more redundant string related manipulation.

Located in /classes/String.php (line 24)


	
			
Method Summary
static string formatPhoneNumber (string $number, [string $replacement = '$1-$2-$3'])
static string generateGravatarHash (string $string)
static boolean isEmpty (string $value)
static string random ([integer $length = 8], [boolean $alpha = true], [boolean $numeric = true], [boolean $similar = true])
static string truncate (string $string, integer $length, [boolean $hover = true])
static string upperWords (string $string)
Methods
static method formatPhoneNumber (line 38)

Format Phone Number

Formats a 10 digit phone number with dashes as ###-###-####.

  • return: formatted phone number
  • access: public
static string formatPhoneNumber (string $number, [string $replacement = '$1-$2-$3'])
  • string $number: number to format
  • string $replacement: output of the string
static method generateGravatarHash (line 60)

Generate Gravatar Hash

Generates a hash from the passed string that can then be used for fetching an avatar from Gravatar.com

  • return: resulting hash
  • access: public
static string generateGravatarHash (string $string)
  • string $string: string to hash, should be an email address
static method isEmpty (line 81)

Is Empty

Checks if a string is empty. You can use the PHP function empty() but that returns true for a string of "0". Last I checked, that's not an empty string. PHP's function also doesn't apply trim() to the value to ensure it's not just a bunch of spaces.

  • return: whether or not the string is empty
  • access: public
static boolean isEmpty (string $value)
  • string $value: string(s) to be checked
static method random (line 111)

Random

Generates a pseudo-random string based on the passed parameters.

Note: Similar characters = 0, O, 1, I (and may be expanded)

  • return: generated string
  • access: public
static string random ([integer $length = 8], [boolean $alpha = true], [boolean $numeric = true], [boolean $similar = true])
  • integer $length: optional length of the generated string
  • boolean $alpha: optional include alpha characters
  • boolean $numeric: optional include numeric characters
  • boolean $similar: optional include similar characters
static method truncate (line 170)

Truncate

Truncates a string to a specified length and (optionally) adds a span to provide a rollover to see the expanded text.

  • return: truncate string
  • access: public
static string truncate (string $string, integer $length, [boolean $hover = true])
  • string $string: string to truncate
  • integer $length: length to truncate to
  • boolean $hover: (optional) whether or not to add the rollover
static method upperWords (line 200)

Upper Words

Applies strtolower() and ucwords() to the passed string. The exception being email addresses which are not formatted at all.

  • return: formatted string
  • access: public
static string upperWords (string $string)
  • string $string: string to format

Documentation generated on Wed, 03 Oct 2012 17:46:06 -0400 by phpDocumentor 1.4.4