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.

TrackingRenamerTrait::renamed()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
/**
3
 * SkipTrait.php
4
 *
5
 * @package         Obfuscator
6
 * @subpackage      NodeVisitor
7
 */
8
9
namespace Naneau\Obfuscator\Node\Visitor;
10
11
/**
12
 * SkipTrait
13
 *
14
 * Renaming trait, for renaming things that require tracking
15
 *
16
 * @category        Naneau
17
 * @package         Obfuscator
18
 * @subpackage      NodeVisitor
19
 */
20
trait TrackingRenamerTrait
21
{
22
    /**
23
     * Renamed variables
24
     *
25
     * @var string[]
26
     **/
27
    private $renamed = array();
28
29
    /**
30
     * Record renaming of method
31
     *
32
     * @param  string    $method
33
     * @param  string    $newName
34
     * @return SkipTrait
0 ignored issues
show
Comprehensibility Bug introduced by
The return type SkipTrait is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
35
     **/
36
    protected function renamed($method, $newName)
37
    {
38
        $this->renamed[$method] = $newName;
39
40
        return $this;
41
    }
42
43
    /**
44
     * Has a method been renamed?
45
     *
46
     * @param  string $method
47
     * @return bool
48
     **/
49
    protected function isRenamed($method)
50
    {
51
        if (empty($method)) {
52
            return false;
53
        }
54
55
        // Ignore variable functions
56
        if (!is_string($method)) {
57
            return false;
58
        }
59
60
        return isset($this->renamed[$method]);
61
    }
62
63
    /**
64
     * Get new name of a method
65
     *
66
     * @param  string $method
67
     * @return string
68
     **/
69
    protected function getNewName($method)
70
    {
71
        if (!$this->isRenamed($method)) {
72
            throw new InvalidArgumentException(sprintf(
73
                '"%s" was not renamed',
74
                $method
75
            ));
76
        }
77
78
        return $this->renamed[$method];
79
    }
80
81
    /**
82
     * Reset renamed list
83
     *
84
     * @return SkipTrait
0 ignored issues
show
Comprehensibility Bug introduced by
The return type SkipTrait is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
85
     **/
86
    protected function resetRenamed()
87
    {
88
        $this->renamed = array();
89
90
        return $this;
91
    }
92
}
93