TidyAdapter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A minify() 0 12 2
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