Passed
Push — main ( 72d047...e456c4 )
by Thierry
02:43
created

FileMinifier   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 4
c 0
b 0
f 0
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A minify() 0 6 1
1
<?php
2
3
/**
4
 * FileMinifier.php - JS and CSS file minifier
5
 *
6
 * Minify the javascript code generated by the Jaxon library and plugins.
7
 *
8
 * @package jaxon-core
9
 * @author Thierry Feuzeu <[email protected]>
10
 * @copyright 2022 Thierry Feuzeu <[email protected]>
11
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
12
 * @link https://github.com/jaxon-php/jaxon-core
13
 */
14
15
namespace Jaxon\Utils\File;
16
17
use MatthiasMullie\Minify\JS as JsMinifier;
18
19
use function is_file;
20
21
class FileMinifier
22
{
23
    /**
24
     * Minify javascript code
25
     *
26
     * @param string $sJsFile The javascript file to be minified
27
     * @param string $sMinFile The minified javascript file
28
     *
29
     * @return bool
30
     */
31
    public function minify(string $sJsFile, string $sMinFile): bool
32
    {
33
        $xJsMinifier = new JsMinifier();
34
        $xJsMinifier->add($sJsFile);
35
        $xJsMinifier->minify($sMinFile);
36
        return is_file($sMinFile);
37
    }
38
}
39