src/Response.php
protected static function splitHeaders($name, $value = null) {
        if (is_string($name)) {
            if (strpos($name, ':') !== false) {
                // The name is in the form Header: value.
                list($name, $value) = explode(':', $name, 2);
                return [static::normalizeHeader(trim($name)) => trim($value)];
            } elseif ($value !== null) {
                return [static::normalizeHeader($name) => $value];
            } else {
                return static::normalizeHeader($name);
            }
        } elseif (is_array($name)) {
            $result = [];
            foreach ($name as $key => $value) {
                if (is_numeric($key)) {
                    // $value should be a header in the form Header: value.
                    list($key, $value) = explode(':', $value, 2);
                }
                $result[static::normalizeHeader(trim($key))] = trim($value);
            }
            return $result;
        }
        throw new \InvalidArgumentException("Argument #1 to splitHeaders() was not valid.", 422);
    }
protected static function splitHeaders($name, $value = null) {
        if (is_string($name)) {
            if (strpos($name, ':') !== false) {
                // The name is in the form Header: value.
                list($name, $value) = explode(':', $name, 2);
                return [static::normalizeHeader(trim($name)) => trim($value)];
            } elseif ($value !== null) {
                return [static::normalizeHeader($name) => $value];
            } else {
                return static::normalizeHeader($name);
            }
        } elseif (is_array($name)) {
            $result = [];
            foreach ($name as $key => $value) {
                if (is_numeric($key)) {
                    // $value should be a header in the form Header: value.
                    list($key, $value) = explode(':', $value, 2);
                }
                $result[static::normalizeHeader(trim($key))] = trim($value);
            }
            return $result;
        }
        throw new \InvalidArgumentException("Argument #1 to splitHeaders() was not valid.", 422);
    }
Split and normalize headers into a form appropriate for {@link $headers} or {@link $globalHeaders}.

@param string|array $name The name of the header or an array of headers.
@param string|null $value The header value if {@link $name} is a string.
@return array|string Returns one of the following:
- array: An array of headers.
- string: The header name if just a name was passed.
@throws \InvalidArgumentException Throws an exception if {@link $name} is not a valid string or array.