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::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
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