Passed
Push — postprocess ( 3926a9 )
by Arnaud
04:40
created

PostProcessHtml::decode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * This file is part of the Cecil/Cecil package.
4
 *
5
 * Copyright (c) Arnaud Ligny <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Cecil\Step;
12
13
use Cecil\Util;
14
use voku\helper\HtmlMin;
15
16
/**
17
 * Post process HTML files.
18
 */
19
class PostProcessHtml extends AbstractPostProcess
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function getName(): string
25
    {
26
        return 'Post-processing HTML';
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function init($options)
33
    {
34
        $this->type = 'html';
35
        parent::init($options);
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function setProcessor(): void
42
    {
43
        $this->processor = new HtmlMin();
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function processFile(\Symfony\Component\Finder\SplFileInfo $file): string
50
    {
51
        $html = Util\File::fileGetContents($file->getPathname());
52
53
        return $this->processor->minify($html);
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function encode(string $content): string
60
    {
61
        return json_encode($content);
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function decode(string $content): string
68
    {
69
        return json_decode($content);
70
    }
71
}
72