Extended::set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace FMUP\Config\Ini;
3
4
use FMUP\Config\Exception;
5
use FMUP\Config\Ini;
6
7
/**
8
 * Class Extended
9
 * Config Ini Extended applies old Zend_Config_Ini inheritance feature
10
 * (in the same component since Zend_Config_Ini is not compliant with composer)
11
 * @package FMUP\Config\Ini
12
 * @uses Zend_Config_Ini (version 1.12.16)
13
 */
14
class Extended extends Ini
15
{
16
    private $config;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
17
18
    /**
19
     * @uses FMUP\Config
20
     * @uses Extended\ZendConfig\Ini
21
     * @return Extended\ZendConfig\Ini
22
     */
23 3
    public function getConfig()
24
    {
25 3
        if (!$this->config) {
26 3
            $this->config = new Extended\ZendConfig\Ini($this->getFilePath(), $this->getSection(), true);
27
        }
28 2
        return $this->config;
29
    }
30
31
    /**
32
     * @param Extended\ZendConfig\Ini $config
33
     * @return $this
34
     */
35 1
    public function setConfig(Extended\ZendConfig\Ini $config)
36
    {
37 1
        $this->config = $config;
38 1
        return $this;
39
    }
40
41
    /**
42
     * @param string $key
43
     * @return mixed|null
44
     */
45 1
    public function get($key = null)
46
    {
47 1
        if (is_null($key)) {
48 1
            return (array)$this->getConfig();
49
        }
50 1
        return $this->has($key) ? $this->getConfig()->$key : null;
51
    }
52
53
    /**
54
     * @param string $paramName
55
     * @return bool
56
     */
57 1
    public function has($paramName)
58
    {
59 1
        return isset($this->getConfig()->$paramName);
60
    }
61
62
    /**
63
     * @param string $paramName
64
     * @param mixed|null $value
65
     * @return $this
66
     */
67 1
    public function set($paramName, $value = null)
68
    {
69 1
        $this->getConfig()->$paramName = $value;
70 1
        return $this;
71
    }
72
}
73