GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ContextManager   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 12
dl 0
loc 58
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A bind() 0 3 1
A get() 0 7 2
A put() 0 8 3
A all() 0 3 1
1
<?php
2
3
namespace Scuttlebyte\ContextManager;
4
5
use Scuttlebyte\ContextManager\Exception\UnregisteredContextException;
6
7
class ContextManager
8
{
9
    /**
10
     * The collection of Contexts
11
     * @var array
12
     */
13
    private $contexts = array();
14
15
    /**
16
     * Add a context to the collection
17
     * @param String|array $key
18
     * @param $value
19
     * @return void
20
     */
21
    public function put($key, $value = null)
22
    {
23
        if (is_array($key)) {
24
            foreach ($key as $arrayKey => $arrayValue) {
25
                $this->bind((string)$arrayKey, $arrayValue);
26
            }
27
        } else {
28
            $this->bind((string)$key, $value);
29
        }
30
    }
31
32
    /**
33
     * Get a value from the contexts
34
     * @param $key
35
     * @throws UnregisteredContextException
36
     * @return mixed
37
     */
38
    public function get($key)
39
    {
40
        if (array_key_exists($key, $this->contexts)) {
41
            return $this->contexts[$key];
42
        }
43
44
        throw new Exception\UnregisteredContextException("No context registered for " . $key);
45
    }
46
47
    /**
48
     * Get all contexts
49
     * @return array
50
     */
51
    public function all()
52
    {
53
        return $this->contexts;
54
    }
55
56
    /**
57
     * Store a key value pair into the collection
58
     * @param String $key
59
     * @param mixed $value
60
     * @return void
61
     */
62
    private function bind(String $key, $value)
63
    {
64
        $this->contexts[$key] = $value;
65
    }
66
}
67