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 ( d9f26b...85f62f )
by Hong
02:17
created

Delegator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
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\Config\Traits\WritableTrait;
20
use Phossa2\Config\Traits\ArrayAccessTrait;
21
use Phossa2\Shared\Reference\DelegatorTrait;
22
use Phossa2\Config\Exception\LogicException;
23
use Phossa2\Config\Interfaces\ConfigInterface;
24
use Phossa2\Shared\Reference\DelegatorInterface;
25
use Phossa2\Config\Interfaces\WritableInterface;
26
27
/**
28
 * Delegator
29
 *
30
 * Implmentation of DelegatorInterface
31
 *
32
 * @package Phossa2\Config
33
 * @author  Hong Zhang <[email protected]>
34
 * @see     ObjectAbstract
35
 * @see     DelegatorInterface
36
 * @version 2.0.0
37
 * @since   2.0.0 added
38
 */
39
class Delegator extends ObjectAbstract implements \ArrayAccess, DelegatorInterface, ConfigInterface, WritableInterface
40
{
41
    use ArrayAccessTrait, DelegatorTrait, WritableTrait;
42
43
    /**
44
     * {@inheritDoc}
45
     */
46
    public function get(/*# string */ $key, $default = null)
47
    {
48
        if ($this->hasInLookup($key)) {
49
            return $this->getFromLookup($key);
50
        }
51
        return $default;
52
    }
53
54
    /**
55
     * {@inheritDoc}
56
     */
57
    public function has(/*# string */ $key)/*# : bool */
58
    {
59
        return $this->hasInLookup($key);
60
    }
61
62
    /**
63
     * {@inheritDoc}
64
     */
65
    public function isWritable()/*# : bool */
66
    {
67
        foreach ($this->lookup_pool as $reg) {
68
            if ($reg instanceof WritableInterface &&
69
                $reg->isWritable()
70
            ) {
71
                $this->setWritable($reg);
72
                return true;
73
            }
74
        }
75
        return false;
76
    }
77
78
    /**
79
     * {@inheritDoc}
80
     */
81
    public function set(/*# string */ $key, $value)
82
    {
83
        if ($this->isWritable()) {
84
            $this->writable->set($key, $value);
85
            return $this;
86
        }
87
        throw new LogicException(
88
            Message::get(Message::CONFIG_NOT_WRITABLE),
89
            Message::CONFIG_NOT_WRITABLE
90
        );
91
    }
92
93
    /**
94
     * {@inheritDoc}
95
     */
96
    protected function isValidRegistry($registry)/*# : bool */
97
    {
98
        return $registry instanceof ConfigInterface;
99
    }
100
101
    /**
102
     * {@inheritDoc}
103
     */
104
    protected function hasInRegistry(
105
        $registry,
106
        /*# string */ $key
107
    )/*# : bool */ {
108
        /* @var $registry ConfigInterface */
109
        return $registry->has($key);
110
    }
111
112
    /**
113
     * {@inheritDoc}
114
     */
115
    protected function getFromRegistry(
116
        $registry,
117
        /*# string */ $key
118
    ) {
119
        /* @var $registry ConfigInterface */
120
        return $registry->get($key);
121
    }
122
}
123