Markdown::parse()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
/**
3
 * The Mardown parser class
4
 */
5
namespace Phile\Plugin\Phile\ParserMarkdown\Parser;
6
7
use Michelf\MarkdownExtra;
8
use Phile\ServiceLocator\ParserInterface;
9
10
/**
11
 * Class Markdown
12
 *
13
 * @author  Frank Nägler
14
 * @link    https://philecms.github.io
15
 * @license http://opensource.org/licenses/MIT
16
 * @package Phile\Plugin\Phile\ParserMarkdown\Parser
17
 */
18
class Markdown implements ParserInterface
19
{
20
    /**
21
     * @var mixed the configuration
22
     */
23
    private $config;
24
25
    /**
26
     * the constructor
27
     *
28
     * @param array $config
29
     */
30 34
    public function __construct(array $config = [])
31
    {
32 34
        $this->config = $config;
33
    }
34
35
    /**
36
     * overload parse with the MarkdownExtra parser
37
     *
38
     * @param string $data
39
     *
40
     * @return string
41
     */
42 7
    public function parse($data)
43
    {
44 7
        $parser = new MarkdownExtra;
45 7
        foreach ($this->config as $key => $value) {
46 7
            $parser->{$key} = $value;
47
        }
48
49 7
        return $parser->transform($data);
50
    }
51
}
52