Completed
Push — master ( 2c7ea9...284ef7 )
by Iman
01:59
created

HtmlMinifier   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 0
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A minify() 0 4 1
1
<?php
2
3
namespace Imanghafoori\Widgets\Utils;
4
5
6
class HtmlMinifier
7
{
8
    private $replace = [
9
        '<!--(.*?)-->' => '', //remove comments
10
        "/<\?php/" => '<?php ',
11
        "/\n([\S])/" => '$1',
12
        "/\r/" => '', // remove carrage return
13
        "/\n/" => '', // remove new lines
14
        "/\t/" => '', // remove tab
15
        "/\s+/" => ' ', // remove spaces
16
    ];
17
    /**
18
     * @return null
19
     */
20
    function minify($htmlString)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
21
    {
22
        return preg_replace(array_keys($this->replace), array_values($this->replace), $htmlString);
23
    }
24
}