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.

SerializableFunc   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 38
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __invoke() 0 12 3
1
<?php
2
3
namespace PhpBoot\Utils;
4
5
/**
6
 * 支持序列化的函数
7
 * @author caoym
8
 *
9
 */
10
class SerializableFunc{
11
    /**
12
     * 方法,绑定参数
13
     * 如
14
     * func,arg1,arg2
15
     * array('a','method1'), arg1,arg2
16
     */
17
    public  function __construct(callable $func){
18
        $args = func_get_args();
19
        $this->func = $func;
20
        $this->bind = array_slice($args,1);
21
    }
22
    
23
    /**
24
     * 
25
     * 调用时,将bind参数加在方法的最前面
26
     * @return mixed
27
     */
28
    public function __invoke(){
29
        $args = func_get_args();
30
        $params = $this->bind;
31
        foreach ($args as $arg){
32
            array_push($params, $arg);
33
        }
34
        $res = call_user_func_array($this->func, $params);
35
        foreach ($this->next as $next){
36
            call_user_func_array($next,$args);
37
        }
38
        return $res;
39
    }
40
    /**
41
     * 串行调用
42
     * @var callable[]
43
     */
44
    public $next=array();
45
    private $bind;
46
    private $func;
47
}
48
49
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...