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