Helper method for sort()
Squashes an array to a single hash so it can be sorted.

@param array $data The data to squash.
@param string|null $key The key for the data.
@return array
485424
protected static function _squash(array $data, $key = null)
    {
        $stack = [];
        foreach ($data as $k => $r) {
            $id = $k;
            if ($key !== null) {
                $id = $key;
            }
            if (is_array($r) && !empty($r)) {
                $stack = array_merge($stack, static::_squash($r, $id));
            } else {
                $stack[] = ['id' => $id, 'value' => $r];
            }
        }

        return $stack;
    }
520481
protected function parseData( array $data, $arrayKey = null )
	{
		if ( is_null( $arrayKey ) )
		{
			$this->files = [];
		}

		foreach ( $data as $key => $value )
		{
			$key = ( $arrayKey ) ? "$arrayKey.$key" : $key;

			// If this value is an instance of the HttpFoundation File class we will
			// remove it from the data array and add it to the files array, which
			// we use to conveniently separate out these files from other data.
			if ( $value instanceof File )
			{
				$this->files[$key] = $value;

				unset( $data[$key] );
			}
			elseif ( is_array( $value ) )
			{
				$this->parseData( $value, $key );
			}
		}

		return $data;
	}
87206
public function translate($key, $data = null)
    {
        $rs = isset($this->data[$key]) ? $this->data[$key] : $key;
        if ($rs && !empty($data)) {
            $names = array_keys($data);
            $names = array_map(function($pkey){ return '{' . $pkey . '}'; }, $names);
            $rs = str_replace($names, array_values($data), $rs);
        }
        return $rs;
    }
132835
private function createManyToOneRelation(array &$data, $key)
    {
        $uid = isset($data[$key]) ? (int)$data[$key] : 0;

        $data[$key] = ($uid > 0)
            ? \Tx_Oelib_MapperRegistry::get($this->relations[$key])->find($uid)
            : null;
    }
604231
public function get($key)
        {
            if (Arrays::is($key)) {
                $result = [];

                foreach($key as $column) {
                    $result[$column] = isset($this->_data[$column]) ? $this->_data[$column] : null;
                }

                return $result;
            } else {
                return isset($this->_data[$key]) ? $this->_data[$key] : null;
            }
        }
288138
public function parse($data, $key = null)
    {
        if ($key) $this->apiKey = $key;
        return $this->get($data, [], null, 'parse');
    }
841583
private static function recursiveKeyExist($data, $key)
    {
        if (empty($key)) {
            return true;
        } else {
            $currentKey = array_shift($key);
            return isset($data[$currentKey]) ? self::recursiveKeyExist($data[$currentKey], $key) : false;
        }
    }
669448
protected function parseKey($key) {
        $key = trim($key);
        $data = explode('.', $key);
        $group = trim($data[0]);
        if (1 == count($data)) {
            return [$group, null];
        }

        return [$group, $data[1]];
    }
1052730
public function shards($key = null)
    {
        $shards = $this->response['_shards'];

        if ($key and isset($shards[$key])) {
            return $shards[$key];
        }

        return $shards;
    }
154559
static function createFromData($key, array $data)
    {
        return new self(
            $key,
            isset($data[self::TYPE_CALL]) ? $data[self::TYPE_CALL] : null,
            isset($data[self::TYPE_TIME]) ? $data[self::TYPE_TIME] : null,
            isset($data[self::TYPE_CPU]) ? $data[self::TYPE_CPU] : null,
            isset($data[self::TYPE_MEMORY_USAGE]) ? $data[self::TYPE_MEMORY_USAGE] : null,
            isset($data[self::TYPE_PEAK_MEMORY_USAGE]) ? $data[self::TYPE_PEAK_MEMORY_USAGE] : null
        );
    }
395138
public function dump($key, array $data)
    {
        $data = Hash::flatten($data);
        array_walk($data, [$this, '_persist'], $key);
        array_filter($data);

        return (bool)$data;
    }
953147
public function getData( $key = NULL ){
		if( is_null( $key ) )
			return $this->data ;
		if( !array_key_exists( $key, $this->data ) )
			return NULL;
		return $this->data[$key];
	}
15734
private function fixArray($data, $key = null)
    {
        if (!is_array($data) || ($key && isset($data[$key]))) {
            $data = [$data];
        }

        return $data;
    }
748924
public function returnOriginalData($key = null)
    {
        $this->_prepareData($key);

        $mergedData = array_merge($this->_DATA, $this->_originalDATA);
        $data       = $this->_removeNewKeys($mergedData);

        if (array_key_exists($key, $data)) {
            return $data[$key];
        }

        return null;
    }
207416
public function toDictionary($key = null)
    {
        $rows = [];
        $key = $key ? : $this->getTable()->getPrimaryKey();
        foreach ($this->rows as $row) {
            $rows[$row->$key] = $row;
        }
        $this->rows = $rows;
        return $this;
    }
603918
public function create(array $data = [], $key = null)
    {
        $type = self::resolveImageType($key);

        return $this->hydrate($type, $data);
    }
294470
public function hmSet($key, array $data) {
        $array = ['hmset', $key];

        foreach ($data as $dataKey => $value) {
            $array[] = $dataKey;
            $array[] = $value;
        }

        return $this->send($array);
    }