Css::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 2
1
<?php
2
3
namespace Knp\MegaMAN\Markdown\Processor;
4
5
use Knp\MegaMAN\Markdown\Processor;
6
use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
7
8
class Css implements Processor
9
{
10
    /**
11
     * @var CssToInlineStyles
12
     */
13
    private $inliner;
14
15
    /**
16
     * @var string
17
     */
18
    private $css;
19
20
    /**
21
     * @param CssToInlineStyles $inliner
22
     * @param string|null       $css
23
     */
24
    public function __construct(CssToInlineStyles $inliner, $css = null)
25
    {
26
        $this->inliner = $inliner;
27
        $this->css     = null !== $css ? $css : sprintf('%s/../../Resources/front/style.css', __DIR__);
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function process($html)
34
    {
35
        $this->inliner->setHTML($html);
36
        $this->inliner->setCSS(file_get_contents($this->css));
37
38
        return $this->inliner->convert();
39
    }
40
}
41