Conditions | 4 |
Paths | 5 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
29 | public function __construct(string $filepath) |
||
30 | { |
||
31 | $stream = file_get_contents($filepath); |
||
32 | |||
33 | // Check if the file has Front Matter. |
||
34 | if (str_starts_with($stream, '---')) { |
||
35 | $object = YamlFrontMatter::markdownCompatibleParse($stream); |
||
36 | |||
37 | if ($object->matter()) { |
||
38 | $this->matter = $object->matter(); |
||
39 | |||
40 | // Unset the slug from the matter, as it can cause problems if it exists. |
||
41 | unset($this->matter['slug']); |
||
42 | } |
||
43 | |||
44 | if ($object->body()) { |
||
45 | $this->body = $object->body(); |
||
46 | } |
||
47 | } else { |
||
48 | $this->body = $stream; |
||
49 | } |
||
65 |