/**
  * @param $value
  */
 public function __construct($value)
 {
     if (null === static::$headerName) {
         throw new InvalidHeaderValueException(sprintf('Header name not defined on class "%s".', get_called_class()));
     }
     GenericHeader::assertHeaderValue($value);
     $this->values = $value;
 }
 /**
  * Factory create AllowHeader from string representation.
  *
  * @param string $headerLine
  *
  * @return $this
  */
 public static function fromString($headerLine)
 {
     list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($headerLine);
     GenericHeader::assertHeaderFieldName('Allow', $fieldName);
     if ($fieldValue !== null) {
         $fieldValue = array_filter(explode(',', $fieldValue), 'trim');
         $fieldValue = array_map('trim', $fieldValue);
     }
     return new static($fieldValue);
 }
 /**
  * Set content type header.
  *
  * @param string $key
  * @param string $value
  *
  * @return $this
  *
  * @throws InvalidHeaderValueException
  */
 public function setParameter($key, $value = null)
 {
     if (null === $this->contentType) {
         throw new InvalidHeaderValueException('Please define content-type first.');
     }
     GenericHeader::assertHeaderValue($key);
     GenericHeader::assertHeaderValue($value);
     $this->parameters[$key] = $value;
     return $this;
 }
 /**
  * Factory create ContentLengthHeader from string representation.
  *
  * @param string $headerLine
  *
  * @return $this
  */
 public static function fromString($headerLine)
 {
     list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($headerLine);
     GenericHeader::assertHeaderFieldName('Content-Length', $fieldName);
     return new static($fieldValue);
 }
 /**
  * Factory create header.
  *
  * @param string $fieldName
  * @param string $fieldValue
  *
  * @return $this
  */
 public static function create($fieldName, $fieldValue)
 {
     GenericHeader::assertHeaderFieldName(static::getHeaderName(), $fieldName);
     return new static($fieldValue);
 }
 /**
  * Assert header value.
  *
  * @param string $value
  *
  * @throws InvalidHeaderValueException
  */
 public static function assertHeaderValue($value)
 {
     if (!GenericHeader::isValidHeaderValue($value)) {
         throw InvalidHeaderValueException::invalidValue($value);
     }
 }
 /**
  * Factory create AgeHeader from string.
  *
  * @param string $headerLine
  *
  * @return $this
  */
 public static function fromString($headerLine)
 {
     list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($headerLine);
     GenericHeader::assertHeaderFieldName('Age', $fieldName);
     return new static($fieldValue !== null ? $fieldValue : null);
 }
 /**
  * Set cookie part.
  *
  * @param string $key
  * @param string $value
  *
  * @return $this
  */
 private function set($key, $value)
 {
     GenericHeader::assertHeaderValue($value);
     $this->parts[$key] = $value;
     return $this;
 }
 /**
  * Constructor.
  *
  * @param DateTime|null $date
  */
 public function __construct(DateTime $date = null)
 {
     GenericHeader::assertEmptyHeaderFieldName(static::$headerName);
     $this->setDate(null !== $date ? $date : new DateTime());
 }
 /**
  * Set cookie.
  *
  * @param string $key
  * @param string $value
  *
  * @return $this
  */
 public function set($key, $value)
 {
     GenericHeader::assertHeaderValue($key);
     GenericHeader::assertHeaderValue($value);
     $this->cookies[$key] = urlencode($value);
     return $this;
 }