Strata\Utility\Hash

Library of array functions for manipulating and extracting data from arrays or 'sets' of data.

`Hash` provides an improved interface, more consistent and
predictable set of features over `Set`. While it lacks the spotty
support for pseudo Xpath, its more fully featured dot notation provides
similar features in a more consistent implementation.

    Synopsis

    class Hash {
    }

    Methods

    protected

    • _filter() — Callback function for filtering.
    • _matchToken() — Check a key against a token.
    • _matches() — Checks whether or not $data matches the attribute patterns
    • _simpleOp() — Perform a simple insert/remove operation.
    • _splitConditions() — Split token conditions
    • _squash() — Helper method for sort() Squashes an array to a single hash so it can be sorted.

    public

    • apply() — Apply a callback to a set of extracted values using `$function`.
    • check() — Test whether or not a given path exists in $data.
    • combine() — Creates an associative array using `$keyPath` as the path to build its keys, and optionally `$valuePath` as path to get the values. If `$valuePath` is not specified, all values will be initialized to null (useful for Hash::merge). You can optionally group the values by what is obtained when following the path specified in `$groupPath`.
    • contains() — Determines if one array contains the exact keys and values of another.
    • diff() — Computes the difference between two complex arrays.
    • dimensions() — Counts the dimensions of an array.
    • expand() — Expands a flat array to a nested array.
    • extract() — Gets the values from an array matching the $path expression.
    • filter() — Recursively filters a data set.
    • flatten() — Collapses a multi-dimensional array into a single dimension, using a delimited array path for each array element's key, i.e. array(array('Foo' => array('Bar' => 'Far'))) becomes array('0.Foo.Bar' => 'Far').)
    • format() — Returns a formatted series of values extracted from `$data`, using `$format` as the format and `$paths` as the values to extract.
    • get() — Get a single value specified by $path out of $data.
    • insert() — Insert $values into an array with the given $path. You can use `{n}` and `{s}` elements to insert $data multiple times.
    • map() — Map a callback across all elements in a set.
    • maxDimensions() — Counts the dimensions of *all* array elements. Useful for finding the maximum number of dimensions in a mixed array.
    • merge() — This function can be thought of as a hybrid between PHP's `array_merge` and `array_merge_recursive`.
    • mergeDiff() — Merges the difference between $data and $compare onto $data.
    • nest() — Takes in a flat array and returns a nested array
    • normalize() — Normalizes an array, and converts it to a standard format.
    • numeric() — Checks to see if all the values in the array are numeric
    • reduce() — Reduce a set of extracted values using `$function`.
    • remove() — Remove data matching $path from the $data array.
    • sort() — Sorts an array by any value, determined by a Set-compatible path