Passed
Branch refactor-markdown-helper (02b3eb)
by Caen
04:15
created

Markdown   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 4
c 2
b 0
f 0
dl 0
loc 15
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 5 2
1
<?php
2
3
namespace Hyde\Framework\Modules\Markdown;
4
5
use Hyde\Framework\Services\MarkdownService;
6
7
/**
8
 * Markdown facade to access Markdown services.
9
 */
10
class Markdown
11
{
12
    /**
13
     * Parse a Markdown string into HTML.
14
     *
15
     * If a source model is provided, the Markdown will be converted using the dynamic MarkdownService,
16
     * otherwise, the pre-configured singleton from the service container will be used instead.
17
     *
18
     * @return string $html
19
     */
20
    public static function parse(string $markdown, ?string $sourceModel = null): string
21
    {
22
        return $sourceModel !== null
23
            ? (new MarkdownService($markdown, $sourceModel))->parse()
24
            : app(MarkdownConverter::class)->convert($markdown);
25
    }
26
}
27