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 ( 71ebec...e04aee )
by Hong
03:28
created

Delegator::has()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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