Util/Array.php

Show: inherited
Table of Contents

\Conjoon_Util_Array

Package: Conjoon\Util\Util

Utility methods for working with arrays.

Author
Thorsten Suckow-Homberg  
Category
Util  

Methods

methodprivate__construct( ) : void

Enforce static behavior.

methodprivate_apply(  $array1,  $array2,  $strict = false,  $preserveExisting = false ) : void
static

Parameters
Name Type Description
$array1
$array2
$strict
$preserveExisting
methodprivate_isAssocCallback(  $a,  $b ) : void
static

Callback for array_reduce-function used in isAssociative

Parameters
Name Type Description
$a
$b
methodpublicapply( array $array1, array $array2 ) : void
static

Applies the key/value pairs from array 2 to array 1.

Overwrites existing keys.

Parameters
Name Type Description
$array1 array
$array2 array
methodpublicapplyIf( array $array1, array $array2 ) : void
static

Applies the key/value pairs from array 2 to array 1, if, and only if this key is not already set in array 1.

Parameters
Name Type Description
$array1 array
$array2 array
methodpublicapplyStrict( array $array1, array $array2 ) : void
static

Applies the key/value pairs from array 2 to array 1, if, and only if the key for the value exists in $array1.

Parameters
Name Type Description
$array1 array
$array2 array
methodpublicarrayKeysExist( array $array, array $keys ) : boolean | string
static

Checks whether a given array provides the listed keys.

The method will eitehr return true if all keys are available or the name of the first key that was missing.

Parameters
Name Type Description
$array array

The associative array to check

$keys array

The list of keys to check for availability in $array

Returns
Type Description
boolean | string either true if none of the keys in $list was missing as a key in $array, or the name of the first key that was found missing
methodpubliccamelizeKeys( Array $array, boolean $return = false ) : Array
static

Camelizes the keys of an assoziative array and returns the array with the new keys, if the second parameter is set to "true".

Otherwise, the reference to the passed argument will be used and the array will be changed directly.

Parameters
Name Type Description
$array Array

The associative array to camelize the keys.

$return boolean

"true" for return a copy of the array with the camelized keys, otherwise false

Returns
Type Description
Array The new array with the keys camelized or null, if the reference is used
Details
Deprecated
use camelizeKeys2 instead  
methodpublicextractByKeys( array $array, array $keys ) : boolean | array
static

Extracts the specified keys from the array and saves them into a new array with their according values.

Parameters
Name Type Description
$array array

The associative array to extract data from

$keys array

The list of keys which values should be extracted from $array

Returns
Type Description
boolean | array either false if a key was missing in $array, or a new array with the extracted values
methodpublicisAssociative( array $array ) : \bollean
static

Checks wether the passed argument is an associative array.

Parameters
Name Type Description
$array array

The array to check for associative keys

Returns
Type Description
\bollean "true", if the array is associative, otherwise "false"
methodpublicunderscoreKeys( Array $array, boolean $return = false ) : Array
static

Underscores the keys of an assoziative array (if camelized) and returns the array with the new keys, if the second parameter is set to "true".

Otherwise, the reference to the passed argument will be used and the array will be changed directly.

Parameters
Name Type Description
$array Array

The associative array to underscore the keys.

$return boolean

"true" for return a copy of the array with the underscored keys, otherwise false

Returns
Type Description
Array The new array with the keys underscored or null, if the reference is used
Documentation was generated by DocBlox 0.18.1.