Completed
Pull Request — master (#2)
by Tomáš
03:12
created

Configuration   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 91.67%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 1
cbo 2
dl 0
loc 48
ccs 11
cts 12
cp 0.9167
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getActiveSniffs() 0 13 3
A normalizeSniffsFromClassesToUnderscoreLowercase() 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\MultiCodingStandard\Configuration;
9
10
use Symplify\MultiCodingStandard\Contract\CodeSniffer\Naming\SniffNamingInterface;
11
use Symplify\MultiCodingStandard\Contract\Configuration\ConfigurationInterface;
12
use Symplify\MultiCodingStandard\Contract\Configuration\MultiCsFileLoaderInterface;
13
14
final class Configuration implements ConfigurationInterface
15
{
16
    /**
17
     * @var MultiCsFileLoaderInterface
18
     */
19
    private $multiCsFileLoader;
20
21
    /**
22
     * @var SniffNamingInterface
23
     */
24
    private $sniffNaming;
25
26
    /**
27
     * @var null|array
28
     */
29
    private $multiCsFile;
30
31 4
    public function __construct(MultiCsFileLoaderInterface $multiCsFileLoader, SniffNamingInterface $sniffNaming)
32
    {
33 4
        $this->multiCsFileLoader = $multiCsFileLoader;
34 4
        $this->sniffNaming = $sniffNaming;
35 4
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 4
    public function getActiveSniffs()
41
    {
42 4
        if ($this->multiCsFile === null) {
43 4
            $this->multiCsFile = $this->multiCsFileLoader->load();
44
        }
45
46 4
        if (isset($this->multiCsFile['sniffs'])) {
47 4
            return $this->normalizeSniffsFromClassesToUnderscoreLowercase($this->multiCsFile['sniffs']);
48
        }
49
50
51
        return [];
52
    }
53
54
    /**
55
     * @return string[]
56
     */
57 4
    private function normalizeSniffsFromClassesToUnderscoreLowercase(array $sniffs)
58
    {
59 4
        return $this->sniffNaming->detectUnderscoreLowercaseFromSniffClasses($sniffs);
60
    }
61
}
62