Completed
Push — master ( 6fb51e...94364b )
by Thierry
01:40
created

Config::setOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Config.php - Trait for config functions
5
 *
6
 * @package jaxon-core
7
 * @author Thierry Feuzeu <[email protected]>
8
 * @copyright 2016 Thierry Feuzeu <[email protected]>
9
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
10
 * @link https://github.com/jaxon-php/jaxon-core
11
 */
12
13
namespace Jaxon\Utils\Traits;
14
15
use Jaxon\DI\Container;
16
17
trait Config
18
{
19
    /**
20
     * Set the value of a config option
21
     *
22
     * @param string        $sName                The option name
23
     * @param mixed         $sValue               The option value
24
     *
25
     * @return void
26
     */
27
    public function setOption($sName, $sValue)
28
    {
29
        return Container::getInstance()->getConfig()->setOption($sName, $sValue);
30
    }
31
32
    /**
33
     * Get the value of a config option
34
     *
35
     * @param string        $sName              The option name
36
     * @param mixed         $xDefault           The default value, to be returned if the option is not defined
37
     *
38
     * @return mixed        The option value, or null if the option is unknown
39
     */
40
    public function getOption($sName, $xDefault = null)
41
    {
42
        return Container::getInstance()->getConfig()->getOption($sName, $xDefault);
43
    }
44
45
    /**
46
     * Check the presence of a config option
47
     *
48
     * @param string        $sName              The option name
49
     *
50
     * @return bool        True if the option exists, and false if not
51
     */
52
    public function hasOption($sName)
53
    {
54
        return Container::getInstance()->getConfig()->hasOption($sName);
55
    }
56
57
    /**
58
     * Get the names of the options matching a given prefix
59
     *
60
     * @param string        $sPrefix        The prefix to match
61
     *
62
     * @return array        The options matching the prefix
63
     */
64
    public function getOptionNames($sPrefix)
65
    {
66
        return Container::getInstance()->getConfig()->getOptionNames($sPrefix);
67
    }
68
69
    /**
70
     * Create a new the config manager
71
     *
72
     * @return Jaxon\Utils\Config\Config            The config manager
73
     */
74
    public function newConfig()
75
    {
76
        return Container::getInstance()->newConfig();
77
    }
78
}
79