Completed
Push — master ( a3f58b...5e1e7e )
by Luca
02:14
created

AbstractRegistryWrapper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 8 2
A get() 0 8 2
1
<?php
2
/**
3
 * OpenFireRestAPI is based entirely on official documentation of the REST API
4
 * Plugin and you can extend it by following the directives of the documentation
5
 *
6
 * For the full copyright and license information, please read the LICENSE
7
 * file that was distributed with this source code. For the full list of
8
 * contributors, visit https://github.com/gnello/PHPOpenFireRestAPI/contributors
9
 *
10
 * @author Luca Agnello <[email protected]>
11
 * @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html
12
 */
13
14
namespace Gnello\OpenFireRestAPI\Wrappers;
15
16
/**
17
 * Class AbstractRegistryWrapper
18
 * @package Gnello\OpenFireRestAPI\Settings
19
 */
20
class AbstractRegistryWrapper
21
{
22
    /**
23
     * @var array
24
     */
25
    private $register = array();
26
27
    /**
28
     * @param $key
29
     * @param $value
30
     * @return mixed
31
     */
32
    protected function set($key, $value)
33
    {
34
        if (is_array($key)) {
35
            return $this->register[$key[0]][] = $value;
36
        }
37
38
        return $this->register[$key] = $value;
39
    }
40
41
    /**
42
     * @param $key
43
     * @return mixed|null
44
     */
45
    protected function get($key)
46
    {
47
        if (!isset($this->register[$key])) {
48
            return null;
49
        }
50
51
        return $this->register[$key];
52
    }
53
}
54