Completed
Push — master ( f42a52...0a9499 )
by Thierry
02:50 queued 01:16
created

Config   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 62
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 3

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setOption() 0 4 1
A getOption() 0 4 1
A hasOption() 0 4 1
A getOptionNames() 0 4 1
A newConfig() 0 4 1
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\Features;
14
15
trait Config
16
{
17
    /**
18
     * Set the value of a config option
19
     *
20
     * @param string        $sName                The option name
21
     * @param mixed         $sValue               The option value
22
     *
23
     * @return void
24
     */
25
    public function setOption($sName, $sValue)
26
    {
27
        return jaxon()->di()->getConfig()->setOption($sName, $sValue);
28
    }
29
30
    /**
31
     * Get the value of a config option
32
     *
33
     * @param string        $sName              The option name
34
     * @param mixed         $xDefault           The default value, to be returned if the option is not defined
35
     *
36
     * @return mixed        The option value, or null if the option is unknown
37
     */
38
    public function getOption($sName, $xDefault = null)
39
    {
40
        return jaxon()->di()->getConfig()->getOption($sName, $xDefault);
41
    }
42
43
    /**
44
     * Check the presence of a config option
45
     *
46
     * @param string        $sName              The option name
47
     *
48
     * @return bool        True if the option exists, and false if not
49
     */
50
    public function hasOption($sName)
51
    {
52
        return jaxon()->di()->getConfig()->hasOption($sName);
53
    }
54
55
    /**
56
     * Get the names of the options matching a given prefix
57
     *
58
     * @param string        $sPrefix        The prefix to match
59
     *
60
     * @return array        The options matching the prefix
61
     */
62
    public function getOptionNames($sPrefix)
63
    {
64
        return jaxon()->di()->getConfig()->getOptionNames($sPrefix);
65
    }
66
67
    /**
68
     * Create a new the config manager
69
     *
70
     * @return Jaxon\Utils\Config\Config            The config manager
71
     */
72
    public function newConfig()
73
    {
74
        return jaxon()->di()->newConfig();
75
    }
76
}
77