Completed
Push — master ( c1b62d...aa607e )
by ARCANEDEV
01:28 queued 11s
created

Markdown::buildParsers()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
cc 2
nc 2
nop 0
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arcanedev\LaravelMarkdown;
6
7
use Arcanedev\LaravelMarkdown\Contracts\Markdown as MarkdownContract;
8
use Illuminate\Contracts\Foundation\Application;
9
use Illuminate\Support\Manager;
10
11
/**
12
 * Class     Markdown
13
 *
14
 * @package  Arcanedev\LaravelMarkdown
15
 * @author   ARCANEDEV <[email protected]>
16
 *
17
 * @method  \Illuminate\Support\HtmlString  parse(string $text)
18
 * @method  void                            begin()
19
 * @method  \Illuminate\Support\HtmlString  end()
20
 *
21
 * @mixin  \Arcanedev\LaravelMarkdown\Parsers\AbstractParser
22
 */
23
class Markdown extends Manager implements MarkdownContract
24
{
25
    /* -----------------------------------------------------------------
26
     |  Main Methods
27
     | -----------------------------------------------------------------
28
     */
29
30
    /**
31
     * Get the default driver name.
32
     *
33
     * @return string
34
     */
35 42
    public function getDefaultDriver(): string
36
    {
37 42
        return $this->config->get('markdown.default');
38
    }
39
40
    /**
41
     * Get the parser instance.
42
     *
43
     * @param  string|null  $driver
44
     *
45
     * @return \Arcanedev\LaravelMarkdown\Contracts\Parser
46
     */
47 6
    public function parser($driver = null)
48
    {
49 6
        return $this->driver($driver);
50
    }
51
52
    /**
53
     * Build all the registered parsers.
54
     */
55 48
    public function buildParsers(): void
56
    {
57 48
        foreach ($this->config->get('markdown.parsers', []) as $name => $parser) {
58
            $this->extend($name, function (Application $app) use ($parser) {
59 42
                return $app->make($parser['class']);
60 48
            });
61
        }
62 48
    }
63
}
64