GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Listener   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 51
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A onAfterFormatFastest() 0 5 1
A onAfterFormat() 0 5 1
A onAfterFormatSmallest() 0 5 1
A compress() 0 17 3
1
<?php
2
3
/*
4
 * This file is part of HtmlCompress.
5
 *
6
 ** (c) 2014 Cees-Jan Kiewiet
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace WyriHaximus\HtmlCompress\Integrations\Sculpin;
12
13
use Sculpin\Core\Event\SourceSetEvent;
14
use WyriHaximus\HtmlCompress\Factory;
15
use WyriHaximus\HtmlCompress\Parser;
16
17
/**
18
 * Class Listener
19
 * @package WyriHaximus\HtmlCompress\Integrations\Sculpin
20
 */
21
class Listener
22
{
23
    /**
24
     * @param SourceSetEvent $event
25
     */
26 1
    public function onAfterFormatFastest(SourceSetEvent $event)
27
    {
28 1
        $parser = Factory::constructFastest();
29 1
        $this->compress($parser, $event);
30 1
    }
31
32
    /**
33
     * @param SourceSetEvent $event
34
     */
35 1
    public function onAfterFormat(SourceSetEvent $event)
36
    {
37 1
        $parser = Factory::construct();
38 1
        $this->compress($parser, $event);
39 1
    }
40
41
    /**
42
     * @param SourceSetEvent $event
43
     */
44 2
    public function onAfterFormatSmallest(SourceSetEvent $event)
45
    {
46 2
        $parser = Factory::constructSmallest();
47 2
        $this->compress($parser, $event);
48 2
    }
49
50
    /**
51
     * @param Parser $parser
52
     * @param SourceSetEvent $event
53
     */
54 1
    protected function compress(Parser $parser, SourceSetEvent $event)
55
    {
56 1
        foreach ($event->allSources() as $source) {
57 1
            $ext = explode('.', $source->filename());
58 1
            $ext = $ext[(count($ext) - 1)];
59 1
            if (in_array(
60 1
                $ext,
61
                [
62 1
                    'html',
63
                    'md',
64
                    'markdown',
65
                ]
66
            )) {
67 1
                $source->setFormattedContent($parser->compress($source->formattedContent()));
68
            }
69
        }
70 1
    }
71
}
72