/** * @param string|null $value */ public function __construct($value = null) { if ($value) { HeaderValue::assertValid($value); $this->value = $value; } }
/** * Create location-based header from string * * @param string $headerLine * @return AbstractLocation * @throws Exception\InvalidArgumentException */ public static function fromString($headerLine) { $locationHeader = new static(); // ZF-5520 - IIS bug, no space after colon list($name, $uri) = GenericHeader::splitHeaderLine($headerLine); // check to ensure proper header type for this factory if (strtolower($name) !== strtolower($locationHeader->getFieldName())) { throw new Exception\InvalidArgumentException('Invalid header line for "' . $locationHeader->getFieldName() . '" header string'); } HeaderValue::assertValid($uri); $locationHeader->setUri(trim($uri)); return $locationHeader; }
/** * Parse a full header line or just the field value part. * * @param string $headerLine */ public function parseHeaderLine($headerLine) { if (strpos($headerLine, ':') !== false) { list($name, $value) = GenericHeader::splitHeaderLine($headerLine); if (strtolower($name) !== strtolower($this->getFieldName())) { $value = $headerLine; // This is just for preserve the BC. } } else { $value = $headerLine; } HeaderValue::assertValid($value); foreach ($this->getFieldValuePartsFromHeaderLine($value) as $value) { $this->addFieldValuePartToQueue($value); } }
/** * Set the content-type character set encoding * * @param string $charset * @return self */ public function setCharset($charset) { HeaderValue::assertValid($charset); $this->parameters['charset'] = $charset; $this->value = null; return $this; }
/** * @param string $path * @return SetCookie */ public function setPath($path) { HeaderValue::assertValid($path); $this->path = $path; return $this; }