Conditions | 4 |
Paths | 4 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
57 | public function parse() |
||
58 | { |
||
59 | if ($this->file->isFile()) { |
||
60 | if (!$this->file->isReadable()) { |
||
61 | throw new \RuntimeException('Cannot read file'); |
||
62 | } |
||
63 | preg_match( |
||
64 | '/'.self::PATTERN.'/s', |
||
65 | $this->file->getContents(), |
||
66 | $matches |
||
67 | ); |
||
68 | // if there is not front matter, set body only |
||
69 | if (empty($matches)) { |
||
70 | $this->body = $this->file->getContents(); |
||
71 | |||
72 | return $this; |
||
73 | } |
||
74 | $this->frontmatter = trim($matches[1]); |
||
75 | $this->body = trim($matches[2]); |
||
76 | } |
||
77 | |||
78 | return $this; |
||
79 | } |
||
80 | |||
101 |