示例#1
0
 /**
  * Parses an article from a string.
  */
 public static function parse(string $data) : self
 {
     $separator = strpos($data, "\r\n\r\n");
     if ($separator === false) {
         throw new FormatException('Invalid article format');
     }
     $headers = HeaderBag::parse(substr($data, 0, $separator + 2));
     $body = substr($data, $separator + 4);
     return new self($body, $headers);
 }