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 ( 3f35d1...706a33 )
by Hong
02:50
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 1
Metric Value
c 1
b 0
f 1
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\Di
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\Di;
16
17
use Phossa2\Di\Message\Message;
18
use Phossa2\Di\Traits\ArrayAccessTrait;
19
use Phossa2\Shared\Base\ObjectAbstract;
20
use Interop\Container\ContainerInterface;
21
use Phossa2\Di\Exception\RuntimeException;
22
use Phossa2\Di\Exception\NotFoundException;
23
use Phossa2\Shared\Reference\DelegatorTrait;
24
use Phossa2\Di\Interfaces\DelegatorInterface;
25
use Phossa2\Config\Interfaces\WritableInterface;
26
27
/**
28
 * Delegator
29
 *
30
 * A writable and array accessable container delegator
31
 *
32
 * @package Phossa2\Di
33
 * @author  Hong Zhang <[email protected]>
34
 * @see     ObjectAbstract
35
 * @see     ContainerInterface
36
 * @see     DelegatorInterface
37
 * @see     WritableInterface
38
 * @see     \ArrayAccess
39
 * @version 2.0.0
40
 * @since   2.0.0 added
41
 */
42
class Delegator extends ObjectAbstract implements DelegatorInterface, \ArrayAccess
43
{
44
    use DelegatorTrait, ArrayAccessTrait;
45
46
    /**
47
     * {@inheritDoc}
48
     */
49
    public function get($id)
50
    {
51
        if ($this->hasInLookup($id)) {
52
            return $this->getFromLookup($id);
53
        } else {
54
            throw new NotFoundException(
55
                Message::get(Message::DI_SERVICE_NOTFOUND, $id),
56
                Message::DI_SERVICE_NOTFOUND
57
            );
58
        }
59
    }
60
61
    /**
62
     * {@inheritDoc}
63
     */
64
    public function has($id)
65
    {
66
        return $this->hasInLookup($id);
67
    }
68
69
    /**
70
     * {@inheritDoc}
71
     */
72
    public function set(/*# string */ $id, $value)
73
    {
74
        if ($this->isWritable()) {
75
            $this->writable->set($id, $value);
76
            return $this;
77
        } else {
78
            throw new RuntimeException(
79
                Message::get(Message::DI_CONTAINER_READONLY, $id),
80
                Message::DI_CONTAINER_READONLY
81
            );
82
        }
83
    }
84
85
    /**
86
     * {@inheritDoc}
87
     */
88
    public function addContainer(ContainerInterface $container)
89
    {
90
        return $this->addRegistry($container);
91
    }
92
93
    /**
94
     * Override 'isWritable()' in 'Phossa2\Config\Traits\WritableTrait'
95
     * {@inheritDoc}
96
     */
97
    public function isWritable()/*# : bool */
98
    {
99
        foreach ($this->lookup_pool as $reg) {
100
            if ($reg instanceof WritableInterface &&
101
                $reg->isWritable()
102
            ) {
103
                $this->setWritable($reg);
104
                return true;
105
            }
106
        }
107
        return false;
108
    }
109
110
    /**
111
     * {@inheritDoc}
112
     */
113
    protected function isValidRegistry($registry)/*# : bool */
114
    {
115
        return $registry instanceof ContainerInterface;
116
    }
117
118
    /**
119
     * {@inheritDoc}
120
     */
121
    protected function hasInRegistry(
122
        $registry,
123
        /*# string */ $key
124
    )/*# : bool */ {
125
        /* @var $registry ContainerInterface */
126
        return $registry->has($key);
127
    }
128
129
    /**
130
     * {@inheritDoc}
131
     */
132
    protected function getFromRegistry(
133
        $registry,
134
        /*# string */ $key
135
    ) {
136
        /* @var $registry ContainerInterface */
137
        return $registry->get($key);
138
    }
139
}
140