@param mixed $data
@param array $keys

@return array
180420
protected function getWildcardValues($data, array $keys) {
        $values = [];

        if ( ! is_array($data) && ! $data instanceof Traversable) {
            if ($data instanceof IArrayable) {
                $data = $data->toArray();
            }

            if ( ! is_array($data)) {
                $data = [];
            }
        }

        if (count($keys) === 0) {
            foreach ($data as $itemKey => $itemValue) {
                $values[$itemKey] = $itemValue;
            }
        }

        if (count($keys) > 0) {
            foreach ($data as $itemKey => $itemValue) {
                // since there are still selector keys left and the next
                // item is not an array, it is safe to skip it
                if ( ! is_array($itemValue)) {
                    continue;
                }

                $nestedValues = $this->getValues($itemValue, $keys);

                foreach ($nestedValues as $nestedKey => $nestedValue) {
                    $values[$this->buildKey($itemKey, $nestedKey)] = $nestedValue;
                }
            }
        }

        return $values;
    }
49781
public function toArray(array $keys = [])
    {
        $data = parent::toArray($keys);

        if (in_array('url', $keys) || empty($keys)) {
            $data['url'] = $this->getUrl();
        }

        if (in_array('is_selected', $keys) || empty($keys)) {
            $data['is_selected'] = (bool) $this->getIsSelected();
        }

        return $data;
    }
313110
protected function arrayDotKeysFlattern(array $data)
    {
        foreach ($data as $name => $values) {
            if ($this->isIterable($values)) {
                foreach ($values as $key => $key_value) {
                    $data["$name.$key"] = $values[$key];
                }
                unset($data[$name]);
            }
        }
        return $data;
    }
1170747
protected function excludeKeys(array $data) {
        $keys = isset($this->config['excludeKeys']) ? $this->config['excludeKeys'] : [];
        foreach ($data as $key => &$value) {
            if (in_array($key, $keys)) {
                unset($data[$key]);
            } else if (is_array($value)) {
                $value = $this->excludeKeys($value);
            }
        }

        return $data;
    }
1234460
public static function key(array $data) {
		$data += [
			'fields' => [],
			'locked' => [],
			'excluded' => []
		];
		return static::_compile(
			array_keys(Set::flatten($data['fields'])),
			$data['locked'],
			array_keys($data['excluded'])
		);
	}
1281302
public function read(array $keys) {
        $res = $this->memcache->getMulti($keys);
        $_res = [];
        if (is_array($res) && sizeof($res) > 0) {
            foreach ($res as $k => $v) {
                $_res[$k] = $v;
            }
        }
        return $_res;
    }
1093076
public function many(array $keys)
    {
        $return = [];

        $prefixedKeys = array_map(function ($key) {
            return $this->prefix . $key;
        }, $keys);

        $values = $this->connection()->mGet($prefixedKeys);

        foreach ($values as $index => $value) {
            $return[$keys[$index]] = is_numeric($value) ? $value : unserialize($value);
        }

        return $return;
    }
202822
public static function keyedAssocToHierarchical($data, $sortKeys = self::DO_NOT_SORT_KEYS)
    {
        if(self::SORT_KEYS == $sortKeys){
            ksort($data);
        }
        $result = array();
        foreach($data as $key=>$value){
            if($value!==null){
                $keys = explode('.',$key);
                $node = $value;
                for($i = count($keys); $i>0; $i--){
                    $k = $keys[$i-1];
                    $node = array($k => $node);
                }
                $result = array_merge_recursive($result, $node);
            }
        }

        return $result;
    }
862256
private function createList(array $keys, array $values)
    {
        $list = [];

        foreach ($keys as $key) {
            if (array_key_exists($key, $values)) {
                $list[$key] = $values[$key];
            }
        }

        return $list;
    }
110593
public static function keysExist(array $data, array $keys): bool
    {
        if (count($keys) > 0) {
            foreach ($keys as $key) {
                if (!array_key_exists($key, $data)) {
                    return false;
                }
            }
        }
        return true;
    }
123190
public static function toBatchData($data, $adds = [])
    {
        foreach ($data as $k => $v) {
            $data[$k] = array_merge([$v], $adds);
        }
        return $data;
    }
495211
protected function getKeyIDs($keys)
    {
        // Force iterator to array with simple temp array
        $map = [];
        foreach ($keys as $key) {
            $map[] = $this->getKeyID($key);
        }
        return $map;
    }
1119654
public function flatKeys(array $keys): array
    {
        $this->search = $keys;
        return $this->flatCollection($this->collection->toArray());
    }
684423
public static function arrayChangeKeys($data, $keyName = 'id')
    {
        $temp = [];
        if (is_array($data)) {
            foreach ($data as $key => $row) {
                if (isset($row[$keyName])) {
                    $temp[$row[$keyName]] = $row;
                } else {
                    $temp[] = $row;
                }
            }
        }
        return $temp;
    }
513472
public function toArray($data, $rootKey = null)
    {
        $data = json_decode($data, true);

        if ($rootKey === null) {
            return $data;
        }

        if (!isset($data[$rootKey])) {
            return [];
        }

        return $data[$rootKey];
    }
205621
public static function withKeys($records, $keys)
    {
        if (!self::iterable($records)) {
            return array();
        }
        
        $out = array();
        foreach ($records as $n => $record) {
            if (!self::iterable($record)) {
                $out[$n] = $record;
                continue;
            }
            $out[$n] = array();
            
            foreach ($record as $k => $v) {
                if (!in_array($k, $keys)) {
                    continue;
                }
                $out[$n][$k] = $v;
            }
        }
        return $out;
    }
1105283
protected function rename(array $data): array
    {
        $result = [];
        foreach ($data as $dataItem) {
            list($keyId, $dataTmp) = $this->getKeyValue($dataItem);

            if ($keyId === null) {
                $result[] = $dataTmp;
            } else {
                $result[$keyId] = $dataTmp;
            }
        }

        return $result;
    }