PHP Class XeroPHP\Helpers

Class Helpers
Mostra file Open project: calcinai/xero-php Class Usage Examples

Public Methods

Method Description
XMLToArray ( SimpleXMLElement $sxml )
arrayToXML ( array $array, null $key_override = null ) : string Convert a multi-d assoc array into an xml representation.
escape ( $string ) : string OAuth compliant escaping functions.
flattenAssocArray ( array $array, string $format, string | null $glue = null, boolean $escape = false ) : string | array Generic function to flatten an associative array into an arbitrarily delimited string.
isAssoc ( array $array )
pluralize ( $string )
singularize ( $string ) : mixed This function is based on Wave\Inflector::singularize().

Method Details

XMLToArray() public static method

public static XMLToArray ( SimpleXMLElement $sxml )
$sxml SimpleXMLElement

arrayToXML() public static method

Straightforward val unless there are numeric keys, in which case, the parent key is singularised and used.
public static arrayToXML ( array $array, null $key_override = null ) : string
$array array
$key_override null
return string

escape() public static method

In php, as simple as rawurlencode(). There were a lot more seemingly redundant transformations in the SimpleOAuth class.
public static escape ( $string ) : string
$string
return string

flattenAssocArray() public static method

Generic function to flatten an associative array into an arbitrarily delimited string.
public static flattenAssocArray ( array $array, string $format, string | null $glue = null, boolean $escape = false ) : string | array
$array array
$format string
$glue string | null
$escape boolean
return string | array If no glue provided, it won't be imploded.

isAssoc() public static method

public static isAssoc ( array $array )
$array array

pluralize() public static method

public static pluralize ( $string )

singularize() public static method

It only contains a fraction of the rules from its predecessor, so only good for a quick basic singularisation.
public static singularize ( $string ) : mixed
$string
return mixed