TidyAdapter::minify()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 12
rs 10
cc 2
nc 2
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Ctw\Middleware\HtmlMinifierMiddleware\Adapter\TidyAdapter;
5
6
use Ctw\Middleware\HtmlMinifierMiddleware\Adapter\AdapterInterface;
7
use tidy;
8
9
class TidyAdapter extends AbstractTidyAdapter implements AdapterInterface
10
{
11
    public function minify(string $htmlSource): string
12
    {
13
        $tidy = tidy_parse_string($htmlSource, $this->getConfig(), 'utf8');
14
        assert($tidy instanceof tidy);
15
16
        //dd($tidy->errorBuffer);
17
18
        if (!tidy_clean_repair($tidy)) {
19
            return $htmlSource;
20
        }
21
22
        return $this->postProcess($tidy->html()->value);
23
    }
24
}
25