Normalizes the results of the above query

@param   array  $data      The raw column data
@param   bool   $typeOnly  True (default) to only return field types
@return  array
@since   2.0.0
976493
public function normalizeColumns($data, $typeOnly = true)
	{
		$results = [];

		// If we only want the type as the value add just that to the list
		if ($typeOnly)
		{
			foreach ($data as $field)
			{
				// @FIXME: should we try to normalize types too?
				$results[$field->name] = $field->type;
			}
		}
		// If we want the whole field data object add that to the list
		else
		{
			foreach ($data as $field)
			{
				$results[$field->name] =
				[
					'name'      => $field->name,
					'type'      => $field->type,
					'allownull' => $field->notnull ? false : true,
					'default'   => $field->dflt_value,
					'pk'        => $field->pk ? true : false
				];
			}
		}

		return $results;
	}
1036926
public static function arrayColumns(array $data)
    {
        // Count the amount of values from the source input
        $count = count($data);

        if ($count === 0) {
            return false;
        }

        if ($count === 1) {
            return array_keys($data[0]);
        }

        if (isset($data[0])) {
            return array_keys($data[0]);
        } else {
            return false;
        }
    }
1136291
public function json($data, $type = 'json') {
        switch (strtolower($type)) {
            case 'xml':
                return Factory::response()->xml($data);
            case 'jsonp':
                return Factory::response()->jsonp($data);
        }
        return Factory::response()->json($data);
    }
642848
protected function  transformData($type, $data)
    {
        foreach ($data as $field => $value) {
            if (isset($this->fields[$field]['options']['transform'])) {
                $data[$field] = $this->transformerManager->{$type.'Form'}($value, $this->fields[$field]['options']['transform']);
            }
        }

        return $data;
    }
1151422
public function supportsDenormalization($data, $type, $format = null)
    {
        $class = $type ?: $this->getClassFromArray($data);
        if (!$this->entityMetadataFactory->hasMetadataFor($class)
        or $this->entityMetadataFactory->getMetadataFor($class)->isEmbeddedClass) {
            return false;
        }

        return parent::supportsDenormalization($data, $type, $format);
    }
1008245
protected function _normalizeData($data)
    {
        $data += [
            'name' => '',
            'empty' => false,
            'disabled' => null,
            'val' => null,
            'year' => [],
            'month' => [],
            'day' => [],
            'hour' => [],
            'minute' => [],
            'second' => [],
            'meridian' => null,
            'templateVars' => [],
        ];

        $timeFormat = isset($data['hour']['format']) ? $data['hour']['format'] : null;
        if ($timeFormat === 12 && !isset($data['meridian'])) {
            $data['meridian'] = [];
        }
        if ($timeFormat === 24) {
            $data['meridian'] = false;
        }

        return $data;
    }
286916
private function convertCompositeFromPg($data, TypeInterface $type)
    {
        $mapping = $this->getMapping($type);

        $out = [];

        foreach ($mapping as $field => $fieldType) {
            if (!isset($data[$field])) {
                $out[$field] = $fieldType instanceof ArrayType ? [] : null;

                continue;
            }

            $out[$field] = $this->fromPg($data[$field], $fieldType);
        }

        if ($normalizer = $this->getNormalizer($type)) {
            $out = $normalizer->fromPg($out, [
                'mapping' => $mapping,
            ]);
        }

        return $out;
    }
358964
private function normalizeData($name, $data)
    {
        if (!isset($this->ignoreProcessing[$name])) {
            return array_map('trim', explode(',', $data));
        } else {
            return [$data];
        }
    }
1155358
protected function normalize(array &$data)
    {
        /**
         * Transforms 'fieldA' to ['fieldA' => ['name' => 'fieldA']]
         * and so will transforms ['fieldA', 'fieldB'] 
         * to [['fieldA' => ['name' => 'fieldA']], ['fieldB' => ['name' => 'fieldB']]].
         *
         * Transforms ['fieldA' => null] to ['fieldA' => ['name' => 'fieldA']].
         *
         * Transforms ['fieldA' => []] to ['fieldA' => ['name' => 'fieldA']].
         *
         * Transforms ['fieldA' => 'fieldARealName'] to ['fieldA' => ['name' => 'fieldARealName']].
         */
        $dataName = 'fields';
        if (isset($data[$dataName])) {
            $normalizedFieldsData = [];

            foreach ($data[$dataName] as $mappedFieldName => $fieldData) {

                if (! isset($fieldData['name'])) {
                    if (is_scalar($fieldData)) {
                        //if $fieldData is a scalar value and a not null value, it contains the field name.
                        $mappedFieldName = $fieldData;
                        $fieldData = [];
                    } elseif (is_null($fieldData)) {
                        $fieldData = [];  
                    }
                    $normalizedFieldsData[$mappedFieldName] = array_merge($fieldData, ['name' => $mappedFieldName]);
                    $data[$dataName] = $normalizedFieldsData;
                    //Otherwise, the key contains the good value for $mappedFieldName.
                }   
            }    
        }

        $processor = new Processor();
        $keysConfiguration = new KeysConfiguration();
        $data = $processor->processConfiguration($keysConfiguration, [$data]);
    }
54655
protected function parseArrayOfPrimaryData(array $data)
    {
        $isValid = true;
        $result  = null;
        foreach ($data as $primaryData) {
            $parsed = $this->parseSinglePrimaryData($primaryData);
            if ($parsed === null) {
                $isValid = false;
            } else {
                $result[] = $parsed;
            }
        }

        return $isValid === true ? $result : null;
    }
190447
public static function type($data = false) {

        if ($data) {

            $dataType = gettype($data);

            if ($dataType === 'string') {

                if (Validate::isJson($data)) {
                    $dataType = 'json';
                }
            }

            return $dataType;
        }

        return false;
    }
461256
public function supportsDenormalization($data, $type, $format = null)
    {
        return in_array($type, static::$types)
           and is_string($data) and preg_match(static::SIMPLE_REGEX, $data) > 0;
    }
1138562
protected function _parseFiles($data) {
		$result = [];

		$normalize = function($key, $value) use ($result, &$normalize){
			foreach ($value as $param => $content) {
				foreach ($content as $num => $val) {
					if (is_numeric($num)) {
						$result[$key][$num][$param] = $val;
						continue;
					}
					if (is_array($val)) {
						foreach ($val as $next => $one) {
							$result[$key][$num][$next][$param] = $one;
						}
						continue;
					}
					$result[$key][$num][$param] = $val;
				}
			}
			return $result;
		};
		foreach ($data as $key => $value) {
			if (isset($value['name'])) {
				if (is_string($value['name'])) {
					$result[$key] = $value;
					continue;
				}
				if (is_array($value['name'])) {
					$result += $normalize($key, $value);
				}
			}
		}
		return $result;
	}
660059
public function secureFields(array $data)
    {
        $data = $this->_normalizeData($data);

        $fields = [];
        foreach ($this->_selects as $select) {
            if ($data[$select] === false || $data[$select] === null) {
                continue;
            }

            $fields[] = $data['name'] . '[' . $select . ']';
        }

        return $fields;
    }
449303
public function supportsDenormalization($data, $type, $format = null): bool
    {
        $reflClass = new \ReflectionClass($type);
        return $reflClass->implementsInterface(DeserializableCommandInterface::class);
    }
1133818
protected function normalize(array $data, int $n): array
    {
        if (count($this->means) === 0) {
            $this->calculateMeans($data, $n);
        }

        // Normalize data
        foreach (array_keys($data) as $i) {
            for ($k = 0; $k < $n; ++$k) {
                $data[$i][$k] -= $this->means[$k];
            }
        }

        return $data;
    }
1266097
protected function normalizeErrorResponse($content, $data = null)
    {
        if ($content instanceof Arrayable) {
            $content = $content->toArray();
        }

        if ( ! is_array($content)) {
            $content = [
                'message' => $content,
            ];
        }

        if (null !== $data) {
            $content['data'] = $data;
        }

        return $content;
    }