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

ensureLineEndingsAreDetected()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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