Passed
Push — master ( 0dab70...882871 )
by Alain
02:20
created

ConfigTrait::getConfigArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Config Trait
4
 *
5
 * @package   BrightNucleus\Config
6
 * @author    Alain Schlesser <[email protected]>
7
 * @license   GPL-2.0+
8
 * @link      http://www.brightnucleus.com/
9
 * @copyright 2016 Alain Schlesser, Bright Nucleus
10
 */
11
12
namespace BrightNucleus\Config;
13
14
use BrightNucleus\Config\ConfigInterface;
15
16
trait ConfigTrait
17
{
18
19
    /**
20
     * Reference to the Config object.
21
     *
22
     * @since 0.1.2
23
     *
24
     * @var ConfigInterface
25
     */
26
    protected $config;
27
28
    /**
29
     * Process the passed-in configuration file.
30
     *
31
     * @since 0.1.2
32
     *
33
     * @param ConfigInterface $config The Config to process.
34
     */
35 1
    protected function processConfig(ConfigInterface $config)
36
    {
37 1
        $this->config = $config;
38 1
    }
39
40
    /**
41
     * Check whether the Config has a specific key.
42
     *
43
     * @since 0.1.2
44
     *
45
     * @param string $key The key to check.
46
     * @return bool Whether the key is known.
47
     */
48 1
    protected function hasConfigKey($key)
49
    {
50 1
        return $this->config->hasKey($key);
51
    }
52
53
    /**
54
     * Get the Config value for a specific key.
55
     *
56
     * @since 0.1.2
57
     *
58
     * @param string $key The key for which to get the value.
59
     * @return mixed Value of the key.
60
     */
61 1
    protected function getConfigKey($key)
62
    {
63 1
        return $this->config->getKey($key);
64
    }
65
66
    /**
67
     * Get a (multi-dimensional) array of all the configuration settings.
68
     *
69
     * @since 0.1.4
70
     *
71
     * @return array All the configuration settings.
72
     */
73 1
    protected function getConfigArray()
74
    {
75 1
        return $this->config->getAll();
76
    }
77
78
    /**
79
     * Get an array of all the keys that are known by the Config.
80
     *
81
     * @since 0.1.2
82
     *
83
     * @return array Array of strings containing all the keys.
84
     */
85 1
    protected function getConfigKeys()
86
    {
87 1
        return $this->config->getKeys();
88
    }
89
}
90