コード例 #1
0
 /**
  * Factory create header from string.
  *
  * @param string $headerLine
  *
  * @return $this
  */
 public static function fromString($headerLine)
 {
     if (null === ($headerName = static::getHeaderName())) {
         GenericHeader::assertEmptyHeaderFieldName($headerName);
     }
     list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($headerLine);
     return static::create($fieldName, $fieldValue);
 }
コード例 #2
0
 /**
  * Factory create CookieHeader from string representation.
  *
  * @param string $headerLine
  *
  * @return $this
  */
 public static function fromString($headerLine)
 {
     list($fieldName, $fieldValue) = GenericHeader::splitHeaderLine($headerLine);
     GenericHeader::assertHeaderFieldName('Cookie', $fieldName);
     $cookies = array();
     foreach (explode(';', $fieldValue) as $item) {
         $parts = explode('=', $item, 2);
         if (2 !== count($parts)) {
             throw new InvalidHeaderValueException(sprintf('Malformed Cookie header found on "%s".', $item));
         }
         list($key, $value) = $parts;
         $cookies[$key] = urldecode($value);
     }
     return new static($cookies);
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
 /**
  * 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);
 }
コード例 #5
0
 /**
  * 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);
 }