Completed
Branch master (c5ceed)
by Tomáš
33:54 queued 13:17
created

RequirementsEventSubscriber   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 32
ccs 0
cts 19
cp 0
rs 10
c 4
b 1
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 6 1
A onConsoleRun() 0 5 1
A ensureLineEndingsAreDetected() 0 4 1
A setupVerbosityToMakeLegacyCodeRun() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of Symplify
5
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
6
 */
7
8
namespace Symplify\PHP7_CodeSniffer\Configuration\EventSubscriber;
9
10
use Symfony\Component\Console\ConsoleEvents;
11
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
12
13
final class RequirementsEventSubscriber implements EventSubscriberInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public static function getSubscribedEvents()
19
    {
20
        return [
21
            ConsoleEvents::COMMAND => 'onConsoleRun'
22
        ];
23
    }
24
25
    public function onConsoleRun()
26
    {
27
        $this->ensureLineEndingsAreDetected();
28
        $this->setupVerbosityToMakeLegacyCodeRun();
29
    }
30
31
    /**
32
     * Ensure this option is enabled or else line endings will not always
33
     * be detected properly for files created on a Mac with the /r line ending.
34
     */
35
    private function ensureLineEndingsAreDetected()
36
    {
37
        ini_set('auto_detect_line_endings', true);
38
    }
39
40
    private function setupVerbosityToMakeLegacyCodeRun()
41
    {
42
        define('PHP_CODESNIFFER_VERBOSITY', 0);
43
    }
44
}
45