Completed
Push — master ( 91a6b3...01a195 )
by Neomerx
04:40
created

ArrayConfig::getConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
nc 1
cc 1
eloc 3
nop 1
crap 1
1
<?php namespace Limoncello\Core\Config;
2
3
/**
4
 * Copyright 2015-2016 [email protected] (www.neomerx.com)
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use Limoncello\Core\Contracts\Config\ConfigInterface;
20
21
/**
22
 * @package Limoncello\Core
23
 */
24
class ArrayConfig implements ConfigInterface
25
{
26
    /**
27
     * @var string[]|null
28
     */
29
    private $interfaces = null;
30
31
    /**
32
     * @var array
33
     */
34
    private $configs;
35
36
    /**
37
     * @param array $configs
38
     */
39 1
    public function __construct(array $configs)
40
    {
41 1
        $this->configs = $configs;
42 1
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47 1
    public function getConfigInterfaces()
48
    {
49 1
        if ($this->interfaces === null) {
50 1
            $this->interfaces = array_keys($this->configs);
0 ignored issues
show
Documentation Bug introduced by
It seems like array_keys($this->configs) of type array<integer,integer|string> is incompatible with the declared type array<integer,string>|null of property $interfaces.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
51
        }
52
53 1
        return $this->interfaces;
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59 1
    public function getConfig($interfaceClass)
60
    {
61 1
        $result = $this->configs[$interfaceClass];
62
63 1
        return $result;
64
    }
65
}
66