From The Smartest Wiki
(Redirected from SmartestString)
Jump to: navigation, search

SmartestString is a class wrapper for strings that is the preferred way that strings are passed to the presentation layer.

When printed without offsets, or the object itself converted to a string via PHP, the object simply produces the string it contains. If the object-to-string conversion happens in Smartest's backend, the raw string will be displayed. On the front end, XML entities will be escaped if they have not already been, and a triple forward-slash (///) will be converted to an HTML line-break (<br />)


SmartestString also has the following offsets, many of which are derived from functionalities in SmartestStringHelper:

String formatting

  • slug - converted to a 'slug'. So "One, Two, Three" is converted to "one-two-three"
  • varname - converted to a variable name. So "One, Two, Three" is converted to "one_two_three"
  • constantname - converted to a constant name. So "One, Two, Three" is converted to "ONE_TWO_THREE"
  • camelcase - converted to a constant name. So "One, Two, Three" is converted to "OneTwoThree"
  • lower or lowercase - converts the string to lowercase
  • upper or uppercase - converts the string to uppercase
  • title or titlecase - converts the string to title case (uppercase first letters) but skips common English prepositions and articles
  • titlecase_strict Same as titlecase but lowercases each word first before making the first letter uppercase.

Markup formatting

  • paragraphs - Uses double line breaks to split the string into pieces, and wraps each piece in a <p></p> tag.
  • encoded
  • urlencoded
  • textile
  • xmlentities
  • html_escape


  • length - The length of the string as an integer
  • wordcount - The word count of the string as an integer
  • empty - return true if the string has a zero length or if the wrapper object has a null value
  • is_md5 - Does the string look like an MD5 hash (32 chars of 0-9 and a-f)? a simple boolean