Neos\Flow\Http\Headers::get PHP Метод

get() публичный Метод

Dates are returned as DateTime objects with the timezone set to GMT.
public get ( string $name ) : array | string
$name string Name of the header, for example "Location", "Content-Description" etc.
Результат 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.
    public function get($name)
    {
        if ($name === 'Cache-Control') {
            return $this->getCacheControlHeader();
        }
        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);
    }

Usage Example

 /**
  * Sets the character set for this message.
  *
  * If the content type of this message is a text/* media type, the character
  * set in the respective Content-Type header will be updated by this method.
  *
  * @param string $charset A valid IANA character set identifier
  * @return self This message, for method chaining
  * @see http://www.iana.org/assignments/character-sets
  * @api
  */
 public function setCharset($charset)
 {
     $this->charset = $charset;
     if ($this->headers->has('Content-Type')) {
         $contentType = $this->headers->get('Content-Type');
         if (stripos($contentType, 'text/') === 0) {
             $matches = [];
             if (preg_match('/(?P<contenttype>.*); ?charset[^;]+(?P<extra>;.*)?/iu', $contentType, $matches)) {
                 $contentType = $matches['contenttype'];
             }
             $contentType .= '; charset=' . $this->charset . (isset($matches['extra']) ? $matches['extra'] : '');
             $this->setHeader('Content-Type', $contentType, true);
         }
     }
     return $this;
 }
All Usage Examples Of Neos\Flow\Http\Headers::get