Retrieve data

Retrieve data from composed input filter, if any; if none, cast the data
passed to the method to an array.

@param mixed $data
@return array
344728
protected function retrieveData($data)
    {
        $filter = $this->getInputFilter();

        if (null !== $filter) {
            return $filter->getValues();
        }

        return (array)$data;
    }
1266749
public function parseReadData($data)
	{
		$results = array();

		foreach ($data as $row) {
			if (is_array($row)) {
				$key = $row['key'];
				$value = $row['value'];
			} elseif (is_object($row)) {
				$key = $row->key;
				$value = $row->value;
			} else {
				$msg = 'Expected array or object, got '.gettype($row);
				throw new \UnexpectedValueException($msg);
			}

			SettingsUtilities::set($results, $key, $value);
		}

		return $results;
	}
1283792
protected function asArray($data)
	{
		$array = array();

		if (is_object($data))
		{
			$data = get_object_vars($data);
		}

		foreach ($data as $k => $v)
		{
			if (is_object($v) || is_array($v))
			{
				$array[$k] = $this->asArray($v);
			}
			else
			{
				$array[$k] = $v;
			}
		}

		return $array;
	}
679244
public static function ksort($data)
    {
        if (static::isArray($data) ) {
            foreach ( $data as &$v ) {
                if (is_array($v)) {
                    $v = static::ksort($v);
                }
            }
        }

        ksort($data);

        return $data;
    }
1229981
protected function apply_filters(array $data) {

		if(empty($this->filters)) return $data;

		foreach($this->filters as $field => $filters) {

			if(!isset($data[$field])) continue;

			$value = $data[$field];

			foreach($filters as $filter) {
				$value = call_user_func($filter, $value);
			}

			$data[$field] = $value;

		}

		return $data;

	}
180283
private function prepareResponseData($data)
    {
        switch (true)
        {
            case is_object($data):
                if (method_exists($data, 'toArray'))
                {
                    $data = $data->toArray();
                }
                else
                {
                    $data = get_object_vars($data);
                }
                $data = $this->prepareResponseData($data);
                break;
            case is_array($data):
                foreach ($data as $key => $value)
                {
                    $data[$key] = $this->prepareResponseData($value);
                }
                break;
        }
        return $data;
    }
872221
protected function _getData(array $data): array
    {
        // Stringify empty values
        if (!empty($data)) {
            foreach ($data as $fieldName => $value) {
                $data[$fieldName] = $this->_stringifyEmptyValue($value);
            }
        }

        return $data;
    }
1367679
protected function &loadFilterData(&$data) {

        if ( empty($this->filterMap) ) {
            return $data;
        }
        $error = null;
        $data = Filter::loadFromModel($data, $this->filterMap, $error);

        if ( $data == false ) {
            WebApplication::getInstance()->getAppError()->setCode(1);
            WebApplication::getInstance()->getAppError()->setMessage($error);
        }
        return $data;
    }
270433
public function getData($data)
    {
        if ($this->hasData($data)) {
            return $this->getAttribute(sprintf('data-%s', $data));
        } else {
            return false;
        }
    }
1025124
public static function fromData(array $data)
    {
        $group = new static(array_map(function ($data) {
            return $data['class']::fromData($data['params']);
        }, $data['constraints']));

        return $group->logicalOperator($data['logicalOperator']);
    }
92273
private function convertSerializedToArray($data)
    {
        $data = @unserialize($data);

        // Maybe the response was a serialized JSON string
        // So let's try to convert that to an array...
        if (is_string($data))
        {
            return $this->convertJsonToArray($data);
        }

        // It could be an object or an array of object
        // but we want a associative array, so use
        // JSON to encode it and then decode it properly...
        if ((is_object($data) or is_array($data)) and $json = $this->convertToJson($data))
        {
            return $this->convertJsonToArray($json);
        }

        return null;
    }
260314
public function unserialize($data) {
        $value = $this->fromData($data);
        foreach ($this->getFilters() as $filter) {
            $value = $filter->toValue($value);
        }
        return $value;
    }
532788
protected function getFilterFromData($data): FilterInterface
    {
        if (($groupAndData = $this->getArrayValue($data, 'and')) !== null) {
            $group = new GroupAndFilter();
            foreach ($groupAndData as $filter) {
                $group->push($this->getFilterFromData($filter));
            }

            return $group;
        }
        if (($groupOrData = $this->getArrayValue($data, 'or')) !== null) {
            $group = new GroupOrFilter();
            foreach ($groupOrData as $filter) {
                $group->push($this->getFilterFromData($filter));
            }

            return $group;
        }

        // No group filter; must be a regular Filter
        $field = $this->getArrayValue($data, 'f');
        return new Filter($field, $this->getArrayValue($data, 'o'), $this->getArrayValue($data, 'd'));
    }
741421
protected function retrieveHandler(array &$data)/*# : array */
    {
        $controller = array_shift($data);
        $action = array_shift($data);
        return [$controller, $action];
    }
982240
protected function asArray($data = []): array
    {
        if ($data instanceof Collection) {
            $data = $data->all();
        } elseif ($data instanceof Arrayable) {
            $data = $data->toArray();
        }

        return $data;
    }
499685
protected function getData($data):array{

		if(is_array($data)){
			return $data;
		}
		elseif($data instanceof Traversable){
			return iterator_to_array($data); // @codeCoverageIgnore
		}

		$msg = 'invalid data';
		$this->logger->error($msg);

		throw new InvalidArgumentException($msg);
	}
1080369
private function retrieveUsedFiltersType($data)
    {
        $usedTypes = array();
        foreach($data as $alias => $filterData) {
            if ($filterData['enabled'] == true){
                $filter = $this->getFilter($alias);
                if (!in_array($filter->applyOn(), $usedTypes)) {
                    array_push($usedTypes, $filter->applyOn());
                }
            }
        }
        
        return $usedTypes;
    }