MarkdownDecorator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 23
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A decorateFile() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Symplify
7
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
8
 */
9
10
namespace Symplify\PHP7_Sculpin\Renderable\Markdown;
11
12
use Michelf\MarkdownExtra;
13
use Symplify\PHP7_Sculpin\Contract\Renderable\DecoratorInterface;
14
use Symplify\PHP7_Sculpin\Renderable\File\AbstractFile;
15
16
final class MarkdownDecorator implements DecoratorInterface
17
{
18
    /**
19
     * @var MarkdownExtra
20
     */
21
    private $markdownExtra;
22
23 8
    public function __construct(MarkdownExtra $markdown)
24
    {
25 8
        $this->markdownExtra = $markdown;
26 8
    }
27
28 5
    public function decorateFile(AbstractFile $file)
29
    {
30
        // skip due to HTML content incompatibility
31 5
        if ($file->getExtension() !== 'md') {
32 2
            return;
33
        }
34
35 3
        $htmlContent = $this->markdownExtra->transform($file->getContent());
36 3
        $file->changeContent($htmlContent);
37 3
    }
38
}
39