Example #1
0
 public function __construct($value)
 {
     if (!HeaderValue::isValid($value)) {
         throw new Exception\InvalidArgumentException('Invalid Date header value detected');
     }
     $this->value = $value;
 }
Example #2
0
 public function __construct($value = null)
 {
     if ($value) {
         HeaderValue::assertValid($value);
         $this->value = $value;
     }
 }
 /**
  * Add a directive
  * For directives like 'max-age=60', $value = '60'
  * For directives like 'private', use the default $value = true
  *
  * @param string $key
  * @param string|bool $value
  * @return CacheControl - provides the fluent interface
  */
 public function addDirective($key, $value = true)
 {
     HeaderValue::assertValid($key);
     if (!is_bool($value)) {
         HeaderValue::assertValid($value);
     }
     $this->directives[$key] = $value;
     return $this;
 }
 /**
  * Set the message id
  *
  * @param string|null $id
  * @return MessageId
  */
 public function setId($id = null)
 {
     if ($id === null) {
         $id = $this->createMessageId();
     }
     if (!HeaderValue::isValid($id) || preg_match("/[\r\n]/", $id)) {
         throw new Exception\InvalidArgumentException('Invalid ID detected');
     }
     $this->messageId = sprintf('<%s>', $id);
     return $this;
 }
Example #5
0
 /**
  * Set arbitrary header value
  * RFC allows any token as value, 'close' and 'keep-alive' are commonly used
  *
  * @param string $value
  * @return Connection
  */
 public function setValue($value)
 {
     HeaderValue::assertValid($value);
     $this->value = strtolower($value);
     return $this;
 }
 /**
  * Set header field value
  *
  * @param  string $fieldValue
  * @return GenericHeader
  */
 public function setFieldValue($fieldValue)
 {
     $fieldValue = (string) $fieldValue;
     HeaderValue::assertValid($fieldValue);
     if (preg_match('/^\\s+$/', $fieldValue)) {
         $fieldValue = '';
     }
     $this->fieldValue = $fieldValue;
     return $this;
 }
Example #7
0
 public function setRangeUnit($rangeUnit)
 {
     HeaderValue::assertValid($rangeUnit);
     $this->rangeUnit = $rangeUnit;
     return $this;
 }
Example #8
0
 public function __construct(\DateTimeInterface $date)
 {
     parent::__construct($date->format(\DateTime::RFC1123));
 }
Example #9
0
 public function __construct(UrlHost $host, PortInterface $port)
 {
     $this->host = $host;
     $this->port = $port;
     parent::__construct($host . (!$port instanceof NullPort ? ':' . $port : ''));
 }