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.

Reflector   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 56
ccs 0
cts 22
cp 0
rs 10
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 3 1
A __construct() 0 3 1
A getCurrentClassMethods() 0 14 5
1
<?php
2
/**
3
 * Class Reflector
4
 *
5
 * @link https://www.icy2003.com/
6
 * @author icy2003 <[email protected]>
7
 * @copyright Copyright (c) 2017, icy2003
8
 */
9
namespace icy2003\php\ihelpers;
10
11
use ReflectionClass;
12
13
/**
14
 * 反射类扩展
15
 */
16
class Reflector
17
{
18
19
    /**
20
     * 加载一个类对象
21
     *
22
     * @param object $object
23
     */
24
    public function __construct($object)
25
    {
26
        $this->__reflector = new ReflectionClass($object);
27
    }
28
29
    /**
30
     *
31
     * 反射对象
32
     *
33
     * @var \ReflectionClass $__reflector
34
     */
35
    private $__reflector;
36
37
    /**
38
     *
39
     * ReflectionClass 类调用方法
40
     *
41
     * @see http://php.net/manual/zh/class.reflectionclass.php
42
     *
43
     * @param string $name 反射类可调用的方法
44
     * @param mixed $arguments 对应的参数
45
     *
46
     * @return mixed
47
     */
48
    public function __call($name, $arguments)
49
    {
50
        return $this->__reflector->$name($arguments);
51
    }
52
    /**
53
     * 获取当前类的所有方法
54
     *
55
     * @param callback $callback 对方法名的回调,true 则返回该方法
56
     * @return array
57
     */
58
    public function getCurrentClassMethods($callback = null)
59
    {
60
        $callback = null === $callback ? function() {
61
            return true;
62
        } : $callback;
63
        $currentClass = $this->__reflector->getName();
64
        $methods = $this->__reflector->getMethods();
65
        $result = [];
66
        foreach ($methods as $method) {
67
            if ($currentClass === $method->class && $callback($method->name)) {
68
                $result[] = $method;
69
            }
70
        }
71
        return $result;
72
    }
73
}
74