Tools

Helper classes for performing common tasks.

class ArrayHelper

collection of static helper functions for working with arrays

countValues(array $array, $caseSensitive = true)

A wrapper around array_count_values() that cleans the array values first, and allows to ignore string case.

class StringHelper

collection of static helper functions for working with strings

BRACKET_SQUARE = '[]'
BRACKET_ROUND = '()'
BRACKET_CURLY = '{}'
BRACKET_CHEVRON = '<>'
canonicalize($string, $toLowerCase = true, $allowDash = false)

cleans a string, leaving only alphanumeric values, and optionally allow dashes.

Parameters:
  • $string (string) – input string
  • $toLowerCase (bool) – transform string to lowercase
  • $allowDash (bool) – remove dashes
Returns:

the canonicalized string

bracesToArray($string, $braces = self::BRACKET_ROUND, $first = true)

explodes strings into arrays based on braces.

$string = "(my)(string(value))";
$array = StringHelper::bracesToArray($string);

// $array now contains:
[
    ["my"],
    [
        ["string"],
        [
            ["value"]
        ]
    ]
]