Returns an $array using $mapping to convert it's original keys.

@example
>>> Arrays::map(array('hello'=>'world','when'=>'now'),array('hello'=>'goodbye'));
array('goodbye'=>'world');
172075
public static function map($array, $mapping) {
        $result = array();
        foreach($mapping as $src=>$dest) {
            if(array_key_exists($src, $array)) {
                $result[$dest] = $array[$src];
            }
        }
        return $result;
    }
844618
function array_map_deep($array, $callback) {
        $new = array();
        if(is_array($array)) foreach ($array as $key => $val) {
            if (is_array($val)) {
                $new[$key] = $this->array_map_deep($val, $callback);
            } else {
                $item = call_user_func($callback, $key, $val);
                $new[$item['key']] = $item['item'];
            }
        }
        else $new = call_user_func($callback, $array);
        return $new;
    }
897510
protected function argKeys(): Collection
    {
        $args = $this->args;

        ksort($args);

        return (new Collection($args))->map(function ($value, $key) {
            $keyValue = is_array($value)
                ? json_encode($value, true)
                : $value;

            return "{$key}:{$keyValue}";
        });
    }
329473
public static function reindex(array $array, array $map, bool $unmapped = true): array
    {
        $reindexed = $unmapped
            ? $array
            : [];

        foreach ($map as $from => $to) {
            if (isset($array[$from])) {
                $reindexed[$to] = $array[$from];
            }
        }

        return $reindexed;
    }
433219
protected function map(array $properties)
    {
        $map = array();

        foreach ($properties as $name => $default) {
            $map[$name] = (true === empty($this->$name)) ? $default : $this->$name;
        }

        return $map;
    }
373200
public function transform($map)
    {
        if (is_callable($map)) {
            return $map($this);
        }

        $data = [];
        foreach ($map as $key) {
            $data[$key] = $this->{$key};
        }

        return $data;
    }
113533
public function arrayChangeCaseKey($array)
    {
        return array_map(function ($item) {
            if (is_array($item)) {
                $item = $this->arrayChangeCaseKey($item);
            }

            return $item;
        }, array_change_key_case($array));
    }
662933
public static function map(
        array $array,
        string $from,
        string $to,
        string $group = null
    ): array {
        $result = [];
        foreach ($array as $item) {
            $key = static::get($item, $from);
            $value = static::get($item, $to);
            if ($group !== null) {
                $result[static::get($item, $group)][$key] = $value;
            } else {
                $result[$key] = $value;
            }
        }
        return $result;
    }
450350
public static function map($data) {

        if(is_array($data) === true) {

            $array = self::arrayResolve($data);
        } else {

            $array = self::stringResolve($data);

        }

        return $array;
    }
973219
private function getIn(array $array, array $keys, $default = null)
    {
        if (!$keys) {
            return $array;
        }

        // This is a micro-optimization, it is fast for non-nested keys, but fails for null values
        if (\count($keys) === 1 && isset($array[$keys[0]])) {
            return $array[$keys[0]];
        }

        $current = $array;
        foreach ($keys as $key) {
            if (!\is_array($current) || !\array_key_exists($key, $current)) {
                return $default;
            }

            $current = $current[$key];
        }

        return $current;
    }
158324
protected function parseMapping(array $mapping) {
        foreach ($mapping['properties'] as $i => $property) {
            $name = $property['name'];
            $type = $property['type'];

            if (!isset($property['column'     ])) $property['column'     ] = $name;
            if (!isset($property['column-type'])) $property['column-type'] = $type;     // TODO: bug, $type may be a custom type

            if (isset($property['primary']) && $property['primary']===true)
                $mapping['identity'] = &$property;

            if (isset($property['version']) && $property['version']===true)
                $mapping['version'] = &$property;

            $column = $property['column'];
            $mapping['columns'][$column] = &$property;

            if ($type=='bool' || $type=='boolean') {
                $mapping['getters']['is'.$name ] = &$property;
                $mapping['getters']['has'.$name] = &$property;
            }
            else {
                $mapping['getters']['get'.$name] = &$property;
            }
            $mapping['properties'][$name] = &$property;
            unset($mapping['properties'][$i], $property);
        };

        if (isset($mapping['relations'])) {
            foreach ($mapping['relations'] as $i => $property) {
                $name  = $property['name' ];
                $assoc = $property['assoc'];

                // any association using a mandatory or optional join table
                if ($assoc=='many-to-many' || isset($property['join-table'])) {
                    if (!isset($property['join-table']))                       throw new RuntimeException('Missing attribute "join-table"="{table_name}" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                    if (!isset($property['key']))
                        $property['key'] = $mapping['identity']['name'];
                    else if (!isset($mapping['properties'][$property['key']])) throw new RuntimeException('Illegal attribute "key"="'.$property['key'].'" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                    if (!isset($property['ref-column']))                       throw new RuntimeException('Missing attribute "ref-column"="{'.$property['join-table'].'.column_name}" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                    if (!isset($property['fk-ref-column']))                    throw new RuntimeException('Missing attribute "fk-ref-column"="{'.$property['join-table'].'.column_name}" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                }

                // one-to-one (using no optional join table)
                else if ($assoc == 'one-to-one') {
                    if (!isset($property['column'])) {
                        if (!isset($property['key']))
                            $property['key'] = $mapping['identity']['name'];
                        else if (!isset($mapping['properties'][$property['key']])) throw new RuntimeException('Illegal attribute "key"="'.$property['key'].'" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                        if (!isset($property['ref-column']))                       throw new RuntimeException('Missing attribute "ref-column"="{column_name}" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                    }
                }

                // one-to-many (using no optional join table)
                else if ($assoc == 'one-to-many') {
                    if (!isset($property['key']))
                        $property['key'] = $mapping['identity']['name'];
                    else if (!isset($mapping['properties'][$property['key']])) throw new RuntimeException('Illegal attribute "key"="'.$property['key'].'" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                    if (!isset($property['ref-column']))                       throw new RuntimeException('Missing attribute "ref-column"="{column_name}" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                }

                // many-to-one (using no optional join table)
                else if ($assoc == 'many-to-one') {
                    if (!isset($property['column'])) throw new RuntimeException('Missing attribute "column"="{column_name}" in relation [name="'.$name.'"  assoc="'.$assoc.'"...] of entity class "'.$mapping['class'].'"');
                }
                else                                 throw new RuntimeException('Illegal attribute "assoc"="'.$assoc.'" in relation [name="'.$name.'"...] of entity class "'.$mapping['class'].'"');

                if (isset($property['column']))
                    $mapping['columns'][$property['column']] = &$property;
                $getter = 'get'.$name;
                $mapping['getters'][$getter] = &$property;
                $mapping['relations'][$name] = &$property;
                unset($mapping['relations'][$i], $property);
            };
        }
        else $mapping['relations'] = [];

        $mapping['columns'] = \array_change_key_case($mapping['columns'], CASE_LOWER);
        $mapping['getters'] = \array_change_key_case($mapping['getters'], CASE_LOWER);

        return $mapping;
    }
966523
public static function keyToCamel($array)
    {
        $result = [];
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $result[Strings::case2camel($key)] = self::keyToCamel($value);
            } else {
                $result[Strings::case2camel($key)] = $value;
            }
        }
        return $result;
    }
148589
private static function returnKey($key, $mappingArray)
    {
        if (!is_array($mappingArray)) {
            return $key;
        }

        foreach ($mappingArray as $mappingKey => $mappingData) {
            if (is_array($mappingData)) {
                if (isset($mappingData[$key])) {
                    return $mappingData[$key];
                }
            }
            else {
                if ($mappingKey == $key) {
                    return $mappingData;
                }
            }
        }
        return $key;
    }
745007
protected function getAnyKey(array $keys)
    {
        foreach($keys as $key)
        {
            $value = $this->getValue($key);

            if(!is_null($value))
            {
                return $value;
            }
        }
    }
1168253
public static function keyToCase($array)
    {
        $result = [];
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $result[Strings::camel2case($key)] = self::keyToCase($value);
            } else {
                $result[Strings::camel2case($key)] = $value;
            }
        }
        return $result;
    }
186213
public function toKeyValue(array $values)
    {
        $result = [];

        foreach ($values as $key => $value) {
            if (is_array($value)) {
                $result[$key] = $this->toKeyValue($value);
            } elseif (is_object($value)) {
                $result[$key] = $this->toKeyValue((array) $value);
            } else {
                $result[$key] = $value;
            }
        }

        return $result;
    }
696609
public function translateArray(array $array)
    {
        $result = array();

        foreach ($array as $key => $value) {
            // Group translation
            if (is_array($value)) {
                $key = $this->translate($key);

                // If group is not created yet, create it
                if (!isset($result[$key])){
                    $result[$key] = array();
                }

                foreach($value as $index => $inner) {
                    $result[$key][$index] = $this->translate($inner);
                }
                
            } else if (is_scalar($value)) {
                $result[$key] = $this->translate($value);
            } else {
                throw new InvalidArgumentException('Invalid array supplied');
            }
        }

        return $result;
    }