| Total Complexity | 10 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 7 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | class MarkdownDocument implements MarkdownDocumentContract |
||
| 17 | { |
||
| 18 | public FrontMatter $matter; |
||
| 19 | public Markdown $markdown; |
||
| 20 | |||
| 21 | /** @deprecated */ |
||
| 22 | public string $body; |
||
| 23 | |||
| 24 | public function __construct(FrontMatter|array $matter = [], Markdown|string $body = '') |
||
| 25 | { |
||
| 26 | $this->matter = $matter instanceof FrontMatter ? $matter : new FrontMatter($matter); |
||
|
|
|||
| 27 | $this->markdown = $body instanceof Markdown ? $body : new Markdown($body); |
||
| 28 | |||
| 29 | $this->body = $this->markdown->body; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function __toString(): string |
||
| 33 | { |
||
| 34 | return $this->markdown; |
||
| 35 | } |
||
| 36 | |||
| 37 | public function matter(string $key = null, mixed $default = null): mixed |
||
| 38 | { |
||
| 39 | return $key ? $this->matter->get($key, $default) : $this->matter; |
||
| 40 | } |
||
| 41 | |||
| 42 | public function markdown(): Markdown |
||
| 43 | { |
||
| 44 | return $this->markdown; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** @deprecated */ |
||
| 48 | public function body(): string |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @deprecated v0.56.0 - Use static::parse() instead |
||
| 55 | */ |
||
| 56 | public static function parseFile(string $localFilepath): static |
||
| 59 | } |
||
| 60 | |||
| 61 | public static function parse(string $localFilepath): static |
||
| 62 | { |
||
| 66 |