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::onAfterFormatSmallest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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