Normalize header value

@param string $name Name of header - some headers should not be normalized.
@param string $data Header data for normalization.

@return array Normalized value of header
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]);
    }
361431
private function sanitizeHeaderName($name)
    {
        $name = str_replace('-', ' ', $name);
        $name = ucwords($name);
        return str_replace(' ', '-', $name);
    }
1227585
protected function normalizeHeaderName($name)
    {
        $name = str_replace('-', '_', strtoupper($name));
        if (!in_array($name, ['CONTENT_LENGTH', 'CONTENT_TYPE'])) {
            $name = 'HTTP_' . $name;
        }

        return $name;
    }
1025951
protected function normalizeKey($name)
	{
		$name = strtolower($name);
		$name = str_replace(array('-', '_'), ' ', $name);
		$name = preg_replace('#^http #', '', $name);
		$name = ucwords($name);
		$name = str_replace(' ', '-', $name);

		return $name;
	}
166208
public function normalizeFormData(array $data)
    {
        if (empty($data)) {
            return $data;
        }

        $renameMap = array_flip($this->renamemap);

        foreach ($renameMap as $customName => $defaultName) {
            if (array_key_exists($customName, $data)) {
                $value = $data[$customName];
                unset($data[$customName]);
                $data[$defaultName] = $value;
            }
        }

        return $data;
    }
327360
public function template($name, $data = null)
  {
    $t = $this->getTemplatesEngine()->make($name);

    if ($data) {
      $t->data($data);
    }

    return $t;
  }
1105939
protected function _getTemplateName($name, array &$data = []) {
        if (isset($this->_callbacks[$name])) {
            $data = call_user_func($this->_callbacks[$name], $data);
        }
        if ($this->_callback) {
            $data = call_user_func($this->_callback, $name, $data);
        }
        if (isset($data['templateName'])) {
            $name = $data['templateName'];
            unset($data['templateName']);
        }
        return $name;
    }
605348
protected function normalize(array $data, int $n)
    {
        if (empty($this->means)) {
            $this->calculateMeans($data, $n);
        }

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

        return $data;
    }
731130
protected function normalizeArray(array $data)
    {
        $ret = [];

        foreach ($data as $key => $value) {
            if (!\is_string($key)) {
                continue;
            }

            $ret[$key[0]] = [
                'value' => $value,
                'pattern' => $key,
            ];
        }

        return $ret;
    }
890166
public function getHeader ($name)
		{
			if (is_array($this->_headers))
			{
				foreach ($this->_headers as $header)
				{
					$data = explode(': ', $header);
					if (count($data) == 2 and $data[ 0 ] == $name)
						return $data[ 1 ];
				}
			}

			return null;
		}
542332
protected static function arrayFormat(array $data, $name)
    {
        $format = "\t'$name' => [\n";

        if (count($data) > 0) {
            foreach ($data as $key => $value) {
                $format .= "\t\t'$key' => $value::class , \n";
            }
        } else {
            $format .= "\t\t//\n";
        }

        $format .= "\t],\n\n";

        return $format;
    }
72050
private static function normalizeHeaders(array $headers): array
    {
        $normalizedHeaders = [];

        foreach ($headers as $name => $values) {
            if (\is_int($name)) {
                [$name, $values] = explode(':', $values, 2);
                $values = [ltrim($values)];
            } elseif (!\is_iterable($values)) {
                $values = (array) $values;
            }

            $normalizedHeaders[$name = strtolower($name)] = [];

            foreach ($values as $value) {
                $normalizedHeaders[$name][] = $value;
            }
        }

        return $normalizedHeaders;
    }
605605
public function normalizeData(array $data): array
    {
        $normalizedMetaData = [];
        foreach ($data as $key => $value) {
            $normalizedKey = strtolower($key);
            $normalizedValue = $this->normalizeValues($normalizedKey, $value);
            $normalizedMetaData[$normalizedKey] = $normalizedValue;
        }

        return $normalizedMetaData;
    }
715213
public function set($name, array $data = [])
    {
        $this->setName($name);
        $this->setData($data);

        return $this->isValid();
    }
264178
public function setData($data)
    {
        $this->data = [];
        $data       = self::normalizeArray($data);

        foreach ($data as $offset => $value) $this->offsetSet($offset, $value);

        return $this;
    }
1147534
public static function createFromArray($name, array $data = [])
    {
        $type = parent::createFromArray($name, $data);
        \assert($type instanceof self);

        foreach ($data as $key => $value) {
            switch ($key) {
                case 'pattern':
                    $type->setPattern($value);

                    break;
                case 'minLength':
                    $type->setMinLength($value);

                    break;
                case 'maxLength':
                    $type->setMaxLength($value);

                    break;
            }
        }

        return $type;
    }