MarkdownDecorator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
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