Exemplo n.º 1
0
 public function __construct($value)
 {
     if (!HeaderValue::isValid($value)) {
         throw new Exception\InvalidArgumentException('Invalid Date header value detected');
     }
     $this->value = $value;
 }
Exemplo n.º 2
0
 /**
  * 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;
 }
Exemplo n.º 3
0
 /**
  * Splits the header line in `name` and `value` parts.
  *
  * @param string $headerLine
  * @return string[] `name` in the first index and `value` in the second.
  * @throws Exception\InvalidArgumentException If header does not match with the format ``name:value``
  */
 public static function splitHeaderLine($headerLine)
 {
     $parts = explode(':', $headerLine, 2);
     if (count($parts) !== 2) {
         throw new Exception\InvalidArgumentException('Header must match with the format "name:value"');
     }
     if (!HeaderValue::isValid($parts[1])) {
         throw new Exception\InvalidArgumentException('Invalid header value detected');
     }
     $parts[1] = ltrim($parts[1]);
     return $parts;
 }