Completed
Push — master ( 9b25f2...d42705 )
by Tomáš
09:42 queued 07:08
created

MarkdownDecorator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A decorateFile() 0 9 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\File;
15
16
final class MarkdownDecorator implements DecoratorInterface
17
{
18
    /**
19
     * @var MarkdownExtra
20
     */
21
    private $markdownExtra;
22
23
    public function __construct(MarkdownExtra $markdown)
24
    {
25
        $this->markdownExtra = $markdown;
26
    }
27
28
    public function decorateFile(File $file)
29
    {
30
        if ($file->getExtension() !== 'md') {
31
            return;
32
        }
33
34
        $htmlContent = $this->markdownExtra->transform($file->getContent());
35
        $file->changeContent($htmlContent);
36
    }
37
}
38