| Conditions | 2 |
| Paths | 2 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | public static function parse(string $content): Document |
||
| 10 | { |
||
| 11 | $pattern = '/^[\s\r\n]?---[\s\r\n]?$/sm'; |
||
| 12 | |||
| 13 | $parts = preg_split($pattern, PHP_EOL.ltrim($content)); |
||
| 14 | |||
| 15 | if (count($parts) < 3) { |
||
| 16 | return new Document([], $content); |
||
| 17 | } |
||
| 18 | |||
| 19 | $matter = Yaml::parse(trim($parts[1])); |
||
| 20 | |||
| 21 | $body = implode(PHP_EOL.'---'.PHP_EOL, array_slice($parts, 2)); |
||
| 22 | |||
| 23 | return new Document($matter, $body); |
||
| 24 | } |
||
| 25 | |||
| 33 |