Normalizes an array.

@param array &$data

@throws Exception\NormalizationException
518904
private function normalizeArray(array &$data)
    {
        $normalizedData = array();

        foreach ($data as $key => $val) {
            $normalizedKey = $this->normalizeString($key);

            if ($normalizedKey !== $key) {
                if (array_key_exists($normalizedKey, $normalizedData)) {
                    throw new NormalizationException(sprintf(
                        'The key "%s" is invalid as it will override the existing key "%s"',
                        $key,
                        $normalizedKey
                    ));
                }
            }

            $normalizedData[$normalizedKey] = $val;
            $key = $normalizedKey;

            if (is_array($val)) {
                $this->normalizeArray($normalizedData[$key]);
            }
        }

        $data = $normalizedData;
    }
670507
public static void normalization(char[] charArray)
    {
        assert charArray != null;
        for (int i = 0; i < charArray.length; i++)
        {
            charArray[i] = CONVERT[charArray[i]];
        }
    }
78577
protected function fillDataArray(array &$data)
    {
        $this->query->chunk(
            static::CHUNK_SIZE,
            function ($records) use (&$data) {
                /** @var Collection|Model[] $records */

                foreach ($records as $record) {

                    $fields = [];

                    foreach ($this->columnStrategies as $key => $strategy) {
                        $fields[] = $strategy->render($record, $this->columns[$key]->source);
                    }

                    $data[] = array_combine($this->columnHeaders, $fields);
                }
            }
        );
    }
1113503
public function denormalizeValue(array $data)
    {
        $processed = array();

        foreach ($data as $docId => $content) {
            $cloned = $content;
            $keys = array_keys($cloned);
            $ofType = array_pop($keys);
            $asArray = ('array' === $ofType)? true : false;

            $value = $content[$ofType];

            Assertion::isJsonString($value, 'Invalid json string in registry');

            $processed[$docId] = json_decode($value, $asArray);
        }

        return $processed;
    }
942443
private function NormalizeArray($Array) {
      $Return = array();
      foreach ($Array as $Key => $Value) {
         if (is_array($Value) === TRUE && array_key_exists(0, $Value) === FALSE) {
            foreach($Value as $k => $v) {
               $Return[$Key.'.'.$k] = $v;
            }
         } else {
            $Return[$Key] = $Value;
         }
      }
      return $Return;
   }
685683
private function normalizeTree(array &$data, $level = 0)
	{
		if ($level === 0 && isset($data['_id']) && is_array($data['_id'])) {
			$data = array_merge($data['_id'], $data);
			unset($data['_id']);
		}

		foreach ($data as &$item) {
			if (is_array($item)) {
				$this->normalizeTree($item, ++$level);
			} elseif (is_object($item)) {
				$item = $this->driver->convertToPhp($item);
			}
		}
	}
791602
public static function normalizeArray(array &$array, int $sort_flags = SORT_REGULAR)
    {
        ksort($array, $sort_flags);

        foreach ($array as $index => &$arr) {
            if (is_array($arr)) {
                ArrayTool::normalizeArray($arr, $sort_flags);
            }

            if (is_array($array[$index]) && empty($array[$index])) {
                unset($array[$index]);
            }
        }
    }
436903
public function import(array $data)
    {
        $this->_params = $this->arrayUtil->merge($this->_params, $data);
    }
484130
public function resetData(array $data)
    {
        $this->data = $data;
        if ($this->existsKey('uid')) {
            if (!$this->hasUid()) {
                $this->setUid((int)$this->data['uid']);
            }
            unset($this->data['uid']);
        }

        $this->markAsLoaded();
        if ($this->hasUid()) {
            $this->markAsClean();
        } else {
            $this->markAsDirty();
        }
    }
231677
public function unserialize($data) {
		$vars = unserialize($data);
		parent::_init();

		foreach ($vars as $key => $value) {
			$this->{$key} = $value;
		}
	}
741106
public function setDataFromArray(array $data)
    {
        foreach ($data as $key => $value) {
            $method = 'set' . ucfirst($key);
            if (method_exists($this, $method)) {
                $this->$method($value);
            }
        }
    }
58708
public function unserialize($data)
    {
        $data = unserialize($data);

        foreach (static::$keys as $key) {
            $this->{$key} = $data[$key];
        }
    }
782976
public function init(array $data = [])
    {
        foreach ($data as $key => $value) {
            $key = $this->getPreparedKey($key);
            $method = 'set' . str_replace(' ', '', $key);

            if (method_exists($this, $method)) {
                $this->{$method}($value);
            }
        }
    }
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]);
    }
162154
public function denormalise(array $data, array $options = [])
    {
        if (empty($data)) {
            return $data;
        }

        if (!isset($options["entityClass"])) {
            throw new NormalisationException("Cannot denormalise data without knowing the main entity class");
        }
        if (!isset($options["metadataProvider"])) {
            throw new NormalisationException("Cannot denormalise data without a metadata provider");
        }

        /** @var EntityMetadataProviderInterface $metadataProvider */
        $this->metadataProvider = $options["metadataProvider"];
        $metadata = $this->metadataProvider->getEntityMetadata($options["entityClass"]);

        // split fields based on prefix
        $prefixedFields = [];
        foreach ($data[0] as $field => $value) {
            $fieldParts = explode("__", $field);
            // if this field has no prefix, set it to an empty string
            if (count($fieldParts) == 1) {
                array_unshift($fieldParts, "");
            }
            // add the field to the prefix's array
            $prefix = $fieldParts[0];
            if (empty($prefixedFields[$prefix])) {
                $prefixedFields[$prefix] = [];
            }
            $prefixedFields[$prefix][$fieldParts[1]] = $field;
        }

        // handle case where only 1 prefix is present
        if (count($prefixedFields) == 1) {
            $fields = array_pop($prefixedFields);
            $primaryKey = $metadata->getPrimaryKey();
            if (isset($fields[$primaryKey])) {
                $this->primaryKeyFields = [$fields[$primaryKey] => true];
            }
            return $this->denormaliseData($data, $fields);
        }

        // complex result set
        if (!isset($options["entityMap"])) {
            throw new NormalisationException("Cannot denormalise data without an entity map");
        }

        $entityMap = $options["entityMap"];

        $collection = $metadata->getCollection();

        if (empty($prefixedFields[$collection])) {
            throw new NormalisationException("The collection '$collection' was not found in the fields array for this record set: '" . implode("', '", array_keys($prefixedFields)) . "'");
        }

        // reset primary key fields
        $this->primaryKeyFields = [];
        $this->treedEntities = [];
        $this->childRowAliases = [];

        $this->createFieldTree($prefixedFields, $entityMap, $collection, $options["entityClass"]);

        reset($data);
        $result = $this->denormaliseData($data, $prefixedFields[$collection], $collection);

        return  $result;
    }
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;
    }
818696
protected function postUnserialize(array $data)
    {
        $this->repoPath = array_pop($data);
        $this->path = array_pop($data);
    }