API Documentation for: 1.1.1
Show:

StringUtils Class

Namespace: Canteen\Utilities

Simple utilities for formatting strings. Located in the namespace Canteen\Utilities.

Item Index

Methods

checkBacktrackLimit

(
  • string
)
static

The default backtrack limit for preg expressions is 100KB, we may have pages which ar larger than 100,000, and need to increase the pcre.backtrack_limit

Parameters:

  • string String

    The string to limit test

convertPropertyToConst

(
  • property
)
String static

Convert a property name (someProperty to const SOME_PROPERTY)

Parameters:

  • property String

    The property name

Returns:

String:

The property name as a constant name format

fnmatchInArray

(
  • needle
  • haystack
)
Boolean static

Works like in_array but uses native fnmatch

Parameters:

  • needle String

    The string to test

  • haystack Array

    The haystack of items

Returns:

Boolean:

If the string is found in the array

generateRandomString

(
  • [length=8]
)
String static

Get a random string of characters (readable-ish format)

Parameters:

  • [length=8] Int optional

    The length of the string to export

Returns:

String:

The string of random characters

isRegex

(
  • str
)
Boolean static

Test a string to see if it's a regular expression

Parameters:

  • str String

    the string to test

Returns:

Boolean:

If the string is a regular expression

isSerialized

(
  • value
  • [result=null]
)
Boolean static

Check to see if a string is serialized, if it is return result

Parameters:

  • value String

    Value to test for serialized form

  • [result=null] Mixed optional

    Result of unserialize() of the $value

Returns:

Boolean:

True if value is serialized data, otherwise false

minify

(
  • buffer
)
String static

Used to remove extra whitespace from a buffer Respects the textareas

Parameters:

  • buffer String

    The output buffer

Returns:

String:

The minified HTML string, remove extra whitespace and returns

multilineEdit

(
  • content
)
String static

Convert multiline text to be displayed within a textarea for editting

Parameters:

  • content String

    The content to update

Returns:

String:

The editable content

multilineSave

(
  • content
)
String static

Convert multiline text to be saved to the database for markup display

Parameters:

  • content String

    The content to save

Returns:

String:

The editable content

propertyToReadable

(
  • property
)
String static

Convert a property name (myProperty) to a readable name (My Property)

Parameters:

  • property String

    The name of the property (lower camel-case)

Returns:

String:

The readable name, title-case

replaceOnce

(
  • search
  • replace
  • subject
)
String static

Replace the first occurrence in a string

Parameters:

  • search String

    The string to search

  • replace String

    The string to replace with

  • subject String

    The string to replace on

Returns:

String:

The result after replacement

requireSeparator

(
  • directory
)
String static

Makes sure to include the trailing slash for a directory path

Parameters:

  • directory String

    The directory path

Returns:

String:

The directory path with included trailing slash

stripBuffer

(
  • buffer
)
String private static

Strip new lines, tabs and extra spaces from a string

Parameters:

  • buffer String

    The string buffer

Returns:

String:

The stripped string

uriToMethodCall

(
  • uri
)
String static

Convert a uri (eg. get-all-users) to method call (e.g. getAllUsers)

Parameters:

  • uri String

    The input uri (lowercase, hyphen separated)

Returns:

String:

The method call name (lower, camel-cased)