Passed
Push — master ( 64b248...baa861 )
by Caen
04:12 queued 11s
created

Markdown   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

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