Completed
Branch master (06cb84)
by Tomáš
06:00
created

ConfigurationResolver::setAllowedValues()   C

Complexity

Conditions 7
Paths 1

Size

Total Lines 49
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 8.2162

Importance

Changes 0
Metric Value
dl 0
loc 49
ccs 17
cts 24
cp 0.7083
rs 6.7272
c 0
b 0
f 0
cc 7
eloc 28
nc 1
nop 0
crap 8.2162
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;
9
10
use Symfony\Component\OptionsResolver\OptionsResolver;
11
12
final class ConfigurationResolver
13
{
14
    /**
15
     * @var OptionsResolver
16
     */
17
    private $optionsResolver;
18
19 1
    public function __construct(OptionsResolver $optionsResolver)
20
    {
21 1
        $this->optionsResolver = $optionsResolver;
22 1
    }
23
24
    public function resolveSource(array $source) : array
25
    {
26
        return $this->resolveSingleOption($source, 'source');
27
    }
28
29 1
    public function resolveStandards(array $standards) : array
30
    {
31 1
        return $this->resolveSingleOption($standards, 'standards');
32
    }
33
34
    public function resolveSniffs(array $sniffs) : array
35
    {
36
        return $this->resolveSingleOption($sniffs, 'sniffs');
37
    }
38
39 1
    private function resolveSingleOption(array $value, string $optionName) : array
40
    {
41 1
        $options = $this->optionsResolver->resolve([
42 1
            $optionName => $value
43
        ]);
44
45
        return $options[$optionName];
46
    }
47
}
48