Markdown   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 32
ccs 7
cts 7
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A parse() 0 8 2
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