-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJShrink.php
More file actions
48 lines (39 loc) · 1.13 KB
/
JShrink.php
File metadata and controls
48 lines (39 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types=1);
/*
* This file is part of the QuidPHP package <https://quidphp.com>
* Author: Pierre-Philippe Emond <emondpph@gmail.com>
* License: https://github.com/quidphp/core/blob/master/LICENSE
*/
namespace Quid\Core\Service;
use JShrink\Minifier;
use Quid\Main;
// jShrink
// class that provides methods to use tedivm/jshrink for minifying JavaScript
class JShrink extends Main\Service
{
// config
protected static array $config = [
'flaggedComments'=>true
];
// trigger
// permet de faire un minify d'une string js fourni en argument
// retourne le js minify
final public function trigger(string $value):string
{
if($value instanceof Main\File\Js)
$value = $value->read(true,true);
return Minifier::minify($value,$this->attr());
}
// staticTrigger
// méthode statique pour créer l'objet et minify la string
// retourne une string
final public static function staticTrigger(string $value,?array $attr=null):string
{
$minifier = new static($attr);
return $minifier->trigger($value);
}
}
// init
JShrink::__init();
?>