Js::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of Cecil.
5
 *
6
 * (c) Arnaud Ligny <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Cecil\Step\Optimize;
15
16
use MatthiasMullie\Minify;
17
18
/**
19
 * JavaScript optimization step.
20
 *
21
 * This class extends the AbstractOptimize class and provides functionality
22
 * to optimize JavaScript files. It uses the MatthiasMullie\Minify library to
23
 * minify JavaScript files, reducing their size and improving load times.
24
 * It initializes with the type 'js' and processes files by minifying them.
25
 */
26
class Js extends AbstractOptimize
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31 1
    public function getName(): string
32
    {
33 1
        return 'Optimizing JS';
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 1
    public function init(array $options): void
40
    {
41 1
        $this->type = 'js';
42 1
        parent::init($options);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 1
    public function setProcessor(): void
49
    {
50 1
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55 1
    public function processFile(\Symfony\Component\Finder\SplFileInfo $file): string
56
    {
57 1
        $minifier = new Minify\JS($file->getPathname());
58
59 1
        return $minifier->minify();
60
    }
61
}
62