public function get($name)
    {
        if (strtolower($name) === 'cache-control') {
            return $this->getCacheControlHeader();
        }

        if (strtolower($name) === 'set-cookie') {
            $cookies = $this->fields['Set-Cookie'] ?? [];
            foreach ($this->cookies as $cookie) {
                $cookies[] = (string)$cookie;
            }

            return $cookies;
        }

        if (!isset($this->fields[$name])) {
            return null;
        }

        $convertedValues = [];
        foreach ($this->fields[$name] as $index => $value) {
            $convertedValues[$index] = \DateTime::createFromFormat(DATE_RFC2822, $value);
            if ($convertedValues[$index] === false) {
                $convertedValues[$index] = $value;
            }
        }

        return (count($convertedValues) > 1) ? $convertedValues : reset($convertedValues);
    }
public function get($name)
    {
        if (strtolower($name) === 'cache-control') {
            return $this->getCacheControlHeader();
        }

        if (strtolower($name) === 'set-cookie') {
            $cookies = $this->fields['Set-Cookie'] ?? [];
            foreach ($this->cookies as $cookie) {
                $cookies[] = (string)$cookie;
            }

            return $cookies;
        }

        if (!isset($this->fields[$name])) {
            return null;
        }

        $convertedValues = [];
        foreach ($this->fields[$name] as $index => $value) {
            $convertedValues[$index] = \DateTime::createFromFormat(DATE_RFC2822, $value);
            if ($convertedValues[$index] === false) {
                $convertedValues[$index] = $value;
            }
        }

        return (count($convertedValues) > 1) ? $convertedValues : reset($convertedValues);
    }
public function get ( $ name ) { if ( strtolower ( $ name ) === 'cache-control' ) { return $ this -> getCacheControlHeader ( ) ; } if ( strtolower ( $ name ) === 'set-cookie' ) { $ cookies = $ this -> fields [ 'Set-Cookie' ] ?? [ ] ; foreach ( $ this -> cookies as $ cookie ) { $ cookies [ ] = ( string ) $ cookie ; } return $ cookies ; } if ( ! isset ( $ this -> fields [ $ name ] ) ) { return null ; } $ convertedValues = [ ] ; foreach ( $ this -> fields [ $ name ] as $ index => $ value ) { $ convertedValues [ $ index ] = \ DateTime :: createFromFormat ( DATE_RFC2822 , $ value ) ; if ( $ convertedValues [ $ index ] === false ) { $ convertedValues [ $ index ] = $ value ; } } return ( count ( $ convertedValues ) > 1 ) ? $ convertedValues : reset ( $ convertedValues ) ; }
Returns the specified HTTP header

Dates are returned as DateTime objects with the timezone set to GMT.

@param string $name Name of the header, for example "Location", "Content-Description" etc.
@return array|string An array of field values if multiple headers of that name exist, a string value if only one value exists and NULL if there is no such header.
@api
Returns the specified HTTP header