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 ( d1dfc2...523ba6 )
by Hong
02:50
created

DelegatorWritableTrait::isWritable()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 12
loc 12
rs 9.2
cc 4
eloc 7
nc 3
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\Traits;
16
17
use Phossa2\Config\Interfaces\WritableInterface;
18
19
/**
20
 * DelegatorWritableTrait
21
 *
22
 * @package Phossa2\Config
23
 * @author  Hong Zhang <[email protected]>
24
 * @see     WritableInterface
25
 * @version 2.0.0
26
 * @since   2.0.0 added
27
 */
28
trait DelegatorWritableTrait
29
{
30
    use WritableTrait;
31
32
    /**
33
     * Override `isWritable()` in the WritableTrait
34
     *
35
     * {@inheritDoc}
36
     */
37 View Code Duplication
    public function isWritable()/*# : bool */
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        foreach ($this->lookup_pool as $reg) {
0 ignored issues
show
Bug introduced by
The property lookup_pool does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
40
            if ($reg instanceof WritableInterface &&
41
                $reg->isWritable()
42
            ) {
43
                $this->setWritable($reg);
44
                return true;
45
            }
46
        }
47
        return false;
48
    }
49
50
    /**
51
     * Override `setWritable()` in the WritableTrait
52
     *
53
     * {@inheritDoc}
54
     */
55
    public function setWritable($writable)
56
    {
57
        // only if is boolean
58
        if (is_bool($writable)) {
59
            if ($writable !== $this->isWritable()) {
60
                $this->setRegistryWritable($writable);
61
            }
62
63
        // set the writable registry
64
        } else {
65
            $this->writable = $writable;
66
        }
67
        return $this;
68
    }
69
70
    /**
71
     * Set underlying registries's writability
72
     *
73
     * @param  bool $writable
74
     * @return $this
75
     * @access protected
76
     */
77
    protected function setRegistryWritable(/*# bool */ $writable)
78
    {
79
        if (false === $writable) {
80
            return $this->setRegistryWritableFalse();
81
        } else {
82
            return $this->setRegistryWritableTrue();
83
        }
84
    }
85
86
    /**
87
     * Set writable to FALSE in all registries
88
     *
89
     * @return $this
90
     * @access protected
91
     */
92
    protected function setRegistryWritableFalse()
93
    {
94
        foreach ($this->lookup_pool as $reg) {
95
            if ($reg instanceof WritableInterface) {
96
                $reg->setWritable(false);
97
            }
98
        }
99
        return $this;
100
    }
101
102
    /**
103
     * Set writable to TRUE at first matching registry
104
     *
105
     * @return $this
106
     * @access protected
107
     */
108 View Code Duplication
    protected function setRegistryWritableTrue()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
109
    {
110
        foreach ($this->lookup_pool as $reg) {
111
            if ($reg instanceof WritableInterface) {
112
                $reg->setWritable(true);
113
                return $this;
114
            }
115
        }
116
        return $this;
117
    }
118
}
119