Passed
Push — master ( c92fa1...cf9754 )
by Radu
01:21
created

AbstractLibrary::getData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace WebServCo\Framework;
3
4
abstract class AbstractLibrary
5
{
6
    private $settings = [];
7
    protected $data = [];
8
    
9
    public function __construct($settings = [])
10
    {
11
        if (is_array($settings)) {
12
            $this->settings = $settings;
13
        }
14
    }
15
    
16
    /**
17
     * @param mixed $key Can be an array, a string,
18
     *                          or a special formatted string
19
     *                          (eg 'app/path/project').
20
     * @param mixed $value The value to be stored.
21
     *
22
     * @return bool True on success and false on failure.
23
     */
24
    final public function setData($key, $value)
25
    {
26
        if (empty($key)) {
27
            return false;
28
        }
29
        $this->data = \WebServCo\Framework\ArrayStorage::set($this->data, $key, $value);
30
        return true;
31
    }
32
    
33
    final public function getData()
34
    {
35
        return $this->data;
36
    }
37
    
38
    final public function setting($key, $defaultValue = false)
39
    {
40
        return \WebServCo\Framework\ArrayStorage::get(
41
            $this->settings,
42
            $key,
43
            $defaultValue
44
        );
45
    }
46
    
47
    final public function data($key, $defaultValue = false)
48
    {
49
        return \WebServCo\Framework\ArrayStorage::get(
50
            $this->data,
51
            $key,
52
            $defaultValue
53
        );
54
    }
55
}
56