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.
Completed
Push — master ( 7b66c6...71ebec )
by Hong
02:19
created

Delegator::getFromRegistry()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
/**
3
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Config
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Config;
16
17
use Phossa2\Config\Message\Message;
18
use Phossa2\Shared\Base\ObjectAbstract;
19
use Phossa2\Shared\Reference\DelegatorTrait;
20
use Phossa2\Config\Exception\LogicException;
21
use Phossa2\Shared\Reference\DelegatorInterface;
22
23
/**
24
 * Delegator
25
 *
26
 * Implmentation of DelegatorInterface
27
 *
28
 * @package Phossa2\Config
29
 * @author  Hong Zhang <[email protected]>
30
 * @see     ObjectAbstract
31
 * @see     DelegatorInterface
32
 * @version 2.0.0
33
 * @since   2.0.0 added
34
 */
35
class Delegator extends ObjectAbstract implements \ArrayAccess, DelegatorInterface, ConfigInterface
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: getFromContainer, hasInContainer, isValidContainer
Loading history...
36
{
37
    use ArrayAccessTrait, DelegatorTrait;
38
39
    /**
40
     * {@inheritDoc}
41
     */
42
    public function get(/*# string */ $key, $default = null)
43
    {
44
        if ($this->hasInLookup($key)) {
45
            return $this->getFromLookup($key);
46
        }
47
        return $default;
48
    }
49
50
    /**
51
     * {@inheritDoc}
52
     */
53
    public function has(/*# string */ $key)/*# : bool */
54
    {
55
        return $this->hasInLookup($key);
56
    }
57
58
    /**
59
     * {@inheritDoc}
60
     */
61
    public function set(/*# string */ $key, $value)
62
    {
63
        // marker
64
        $set = false;
65
66
        // set in all registry which has this $key
67
        foreach ($this->lookup_pool as $reg) {
68
            /* @var $reg ConfigInterface */
69
            if ($reg->has($key)) {
70
                $set = true;
71
                $reg->set($key, $value);
72
            }
73
        }
74
75
        // still not set, set in the first reg then
76
        if (false === $set && isset($this->lookup_pool[0])) {
77
            /* @var $reg ConfigInterface */
78
            $reg = $this->lookup_pool[0];
79
            $reg->set($key, $value);
80
            $set = true;
81
        }
82
83
        // no registry found
84
        if (false === $set) {
85
            throw LogicException(
86
                Message::get(Message::CONFIG_NOT_IN_DELEGATOR),
87
                Message::CONFIG_NOT_IN_DELEGATOR
88
            );
89
        }
90
91
        return $this;
92
    }
93
94
    /**
95
     * {@inheritDoc}
96
     */
97
    protected function isValidRegistry($registry)/*# : bool */
98
    {
99
        return $registry instanceof ConfigInterface;
100
    }
101
102
    /**
103
     * {@inheritDoc}
104
     */
105
    protected function hasInRegistry(
106
        $registry,
107
        /*# string */ $key
108
    )/*# : bool */ {
109
        /* @var $registry ConfigInterface */
110
        return $registry->has($key);
111
    }
112
113
    /**
114
     * {@inheritDoc}
115
     */
116
    protected function getFromRegistry(
117
        $registry,
118
        /*# string */ $key
119
    ) {
120
        /* @var $registry ConfigInterface */
121
        return $registry->get($key);
122
    }
123
}
124