Test Failed
Pull Request — master (#1676)
by Arnaud
04:53
created

Html   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

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