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

ConfigurationResolver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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