Beispiel #1
0
 /**
  * Parse a string
  *
  * @param string $header
  */
 public function parseString($header)
 {
     $parts = explode("\r\n", $header, 2);
     if (count($parts) !== 2) {
         throw new InvalidArgumentException("invalid value provided for 'header'; expecting a string that " . "utilizes \\r\\n line breaks");
     }
     list($info, $fields) = $parts;
     list($protocol, $code, $message) = preg_split("/\\s+/", $info, 3);
     $this->protocol = $protocol;
     $this->statusCode = intval($code);
     $lines = explode("\r\n", trim($fields));
     foreach ($lines as $line) {
         list($key, $value) = explode(":", $line, 2);
         $key = strtolower($key);
         $value = trim($value);
         Arr::addvalue($this->fields, $key, $value);
     }
 }