Passed
Pull Request — master (#10)
by Korotkov
01:41
created

ContainerConfigTrait::config()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Korotkov Danila <[email protected]>
7
 * @copyright Copyright (c) 2017, Korotkov Danila
8
 * @license   http://www.gnu.org/licenses/gpl.html GNU GPLv3.0
9
 */
10
11
namespace Rudra\Traits;
12
13
/**
14
 * Trait ContainerConfigTrait
15
 * @package Rudra
16
 */
17
trait ContainerConfigTrait
18
{
19
20
    /**
21
     * @var array
22
     */
23
    protected $config = [];
24
25
    /**
26
     * @param string      $key
27
     * @param string|null $subKey
28
     * @return mixed
29
     */
30
    public function config(string $key, string $subKey = null)
31
    {
32
        return ($subKey === null) ? $this->config[$key] : $this->config[$key][$subKey];
33
    }
34
35
    /**
36
     * @param array $config
37
     */
38
    public function setConfig(array $config): void
39
    {
40
        $this->config = $config;
41
    }
42
}
43