UserFrosting API

Util

Util Class.

Static utility functions.

Tags
author

Alex Weissman (https://alexanderweissman.com)

Table of Contents

extractFields() Extracts specific fields from one associative array, and places them into another. array
extractDigits() Extracts numeric portion of a string (for example, for normalizing phone numbers). string
formatPhoneNumber() Formats a phone number as a standard 7- or 10-digit string (xxx) xxx-xxxx. string
prettyPrintArray() Nicely format an array for printing. string
randomPhrase() Generate a random phrase, consisting of a specified number of adjectives, followed by a noun. string

Methods

extractFields()

Extracts specific fields from one associative array, and places them into another.

public static extractFields( &$inputArray : array , $fieldArray : string[] [, $remove : bool = true ] ) : array
Parameters
$inputArray : array
$fieldArray : string[]
$remove : bool = true
Return values
array

extractDigits()

Extracts numeric portion of a string (for example, for normalizing phone numbers).

public static extractDigits( $str : string ) : string
Parameters
$str : string
Return values
string

formatPhoneNumber()

Formats a phone number as a standard 7- or 10-digit string (xxx) xxx-xxxx.

public static formatPhoneNumber( $phone : string ) : string
Parameters
$phone : string
Return values
string

randomPhrase()

Generate a random phrase, consisting of a specified number of adjectives, followed by a noun.

public static randomPhrase( $numAdjectives : int [, $maxLength : int = 9999999 ] [, $maxTries : int = 10 ] [, $separator : string = '-' ] ) : string
Parameters
$numAdjectives : int
$maxLength : int = 9999999
$maxTries : int = 10
$separator : string = '-'
Return values
string

Search results