Completed
Push — dev-master ( de6724...8ed987 )
by Derek Stephen
11:59
created

Registry::getAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
4
namespace Bone\Mvc;
5
6
/**
7
 * Ahoy there! This here class will store all o' t' configuration
8
 * variables we have for our app'ication
9
 * Class Registry
10
 * @package Bone\Mvc
11
 */
12
class Registry
13
{
14
    /**
15
     * @var array
16
     * @access private
17
     */
18
    private $vars = [];
19
20
21
    /**
22
     *  There be nay feckin wi' constructors on board this ship
23
     *  There be nay copyin' o' th'ship either
24
     *  This ship is a singleton!
25
     */
26
    public function __construct(){}
27
    public function __clone(){}
28
29
30
    /**
31
     *  Ahoy! There nay be boardin' without yer configuration
32
33
     * @return Registry
34
     */
35 46
    public static function ahoy(): Registry
36 46
    {
37 46
        static $inst = null;
38 46
        if($inst === null)
39
        {
40 1
            $inst = new Registry();
41
        }
42 46
        return $inst;
43
    }
44
45
    /**
46
     * What would you like us t' remember for you?
47
     * @param $index
48
     * @param $value
49
     */
50 36
    public function set(string $index, $value)
51 36
    {
52 36
        $this->vars[$index] = $value;
53 36
    }
54
55
    /**
56
     * You would like t' remember somethin'?
57
     * @param string $index
58
     * @return mixed
59
     */
60 44
    public function get($index)
61 44
    {
62 44
        return isset($this->vars[$index]) ? $this->vars[$index] : null;
63
    }
64
65
    /**
66
     * @return array
67
     */
68 1
    public function getAll(): array
69 1
    {
70 1
        return $this->vars;
71
    }
72
}