PHP Class Parkour\Transform

Show file Open project: benjamminf/craft-embedded-assets Class Usage Examples

Public Methods

Method Description
combine ( array $data, callable $cb, boolean $overwrite = true ) : array Indexes an array depending on the values it contains.
merge ( array $first, array $second ) : array Merges two arrays recursively.
normalize ( array $data, mixed $default ) : array Makes every value that is numerically indexed a key, given $default as value.
reindex ( array $data, array $map, $keepUnmapped = true ) : array Reindexes a list of values.

Method Details

combine() public static method

Indexes an array depending on the values it contains.
public static combine ( array $data, callable $cb, boolean $overwrite = true ) : array
$data array Data.
$cb callable Function to combine values.
$overwrite boolean Should duplicate keys be overwritten ?
return array Indexed values.

merge() public static method

Merges two arrays recursively.
public static merge ( array $first, array $second ) : array
$first array Original data.
$second array Data to be merged.
return array Merged data.

normalize() public static method

Makes every value that is numerically indexed a key, given $default as value.
public static normalize ( array $data, mixed $default ) : array
$data array Data.
$default mixed Default value.
return array Normalized values.

reindex() public static method

Reindexes a list of values.
public static reindex ( array $data, array $map, $keepUnmapped = true ) : array
$data array Data.
$map array An map of correspondances of the form ['currentIndex' => 'newIndex'].
return array $keepUnmapped Whether or not to keep keys that are not remapped.