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

AbstractLibrary   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A setData() 0 7 2
A setting() 0 6 1
A getData() 0 3 1
A data() 0 6 1
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