| Total Complexity | 9 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | class MarkdownDocument implements MarkdownDocumentContract, Arrayable |
||
| 16 | { |
||
| 17 | public array $matter; |
||
| 18 | public string $body; |
||
| 19 | |||
| 20 | public function __construct(array $matter = [], string $body = '') |
||
| 21 | { |
||
| 22 | $this->matter = $matter; |
||
| 23 | $this->body = $body; |
||
| 24 | } |
||
| 25 | |||
| 26 | public function __toString(): string |
||
| 27 | { |
||
| 28 | return $this->body; |
||
| 29 | } |
||
| 30 | |||
| 31 | public function __get(string $key): mixed |
||
| 32 | { |
||
| 33 | return $this->matter($key); |
||
| 34 | } |
||
| 35 | |||
| 36 | public function matter(string $key = null, mixed $default = null): mixed |
||
| 37 | { |
||
| 38 | if ($key) { |
||
| 39 | return Arr::get($this->matter, $key, $default); |
||
| 40 | } |
||
| 41 | |||
| 42 | return $this->matter; |
||
| 43 | } |
||
| 44 | |||
| 45 | public function body(): string |
||
| 48 | } |
||
| 49 | |||
| 50 | public function render(): string |
||
| 51 | { |
||
| 52 | return Markdown::parse($this->body); |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Return the Markdown document body explored by line into an array. |
||
| 57 | */ |
||
| 58 | public function toArray(): array |
||
| 59 | { |
||
| 60 | return explode("\n", $this->body); |
||
|
|
|||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @deprecated v0.56.0 - Will be renamed to parse() |
||
| 65 | */ |
||
| 66 | public static function parseFile(string $localFilepath): static |
||
| 69 | } |
||
| 70 | } |
||
| 71 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: