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 ( 67299f...cefe9c )
by Hong
02:18
created

DelegatorWritableTrait::setRegistryWritable()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 8
rs 9.4285
cc 2
eloc 5
nc 2
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\Traits;
16
17
use Phossa2\Shared\Delegator\DelegatorTrait;
18
use Phossa2\Config\Interfaces\WritableInterface;
19
20
/**
21
 * DelegatorWritableTrait
22
 *
23
 * Writable for delegator
24
 *
25
 * @package Phossa2\Config
26
 * @author  Hong Zhang <[email protected]>
27
 * @see     WritableInterface
28
 * @version 2.0.8
29
 * @since   2.0.0 added
30
 * @since   2.0.7 changed to Delegator\DelegatorTrait
31
 */
32
trait DelegatorWritableTrait
33
{
34
    use WritableTrait, DelegatorTrait;
35
36
    /**
37
     * Override `isWritable()` in the WritableTrait.
38
     *
39
     * Delegator's writability is base on its registries
40
     *
41
     * {@inheritDoc}
42
     */
43
    public function isWritable()/*# : bool */
44
    {
45
        foreach ($this->lookup_pool as $reg) {
46
            if ($reg instanceof WritableInterface &&
47
                $reg->isWritable()
48
            ) {
49
                $this->setWritable($reg);
50
                return true;
51
            }
52
        }
53
        return false;
54
    }
55
56
    /**
57
     * Override `setWritable()` in the WritableTrait
58
     *
59
     * {@inheritDoc}
60
     */
61
    public function setWritable($writable)
62
    {
63
        if ($writable === $this->isWritable()) {
64
            return $this;
65
        } elseif (false === $writable) {
66
            $this->setRegistryWritableFalse();
67
        } elseif (true === $writable) {
68
            $this->setRegistryWritableTrue();
69
        } else {
70
            $this->writable = $writable;
71
        }
72
        return $this;
73
    }
74
75
    /**
76
     * Set writable to FALSE in all registries
77
     *
78
     * @return $this
79
     * @access protected
80
     */
81
    protected function setRegistryWritableFalse()
82
    {
83
        foreach ($this->lookup_pool as $reg) {
84
            if ($reg instanceof WritableInterface) {
85
                $reg->setWritable(false);
86
            }
87
        }
88
        return $this;
89
    }
90
91
    /**
92
     * Set writable to TRUE at first matching registry
93
     *
94
     * @return $this
95
     * @access protected
96
     */
97
    protected function setRegistryWritableTrue()
98
    {
99
        foreach ($this->lookup_pool as $reg) {
100
            if ($reg instanceof WritableInterface) {
101
                $reg->setWritable(true);
102
                break;
103
            }
104
        }
105
        return $this;
106
    }
107
}
108