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.

FunctionInvoker   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 40
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A invoke() 0 4 1
A invokeWithArgs() 0 10 2
1
<?php
2
3
namespace TaskQueue\Invoker;
4
5
use TaskQueue\Invoker\Exception\InvalidCallableTypeException;
6
7
class FunctionInvoker implements InvokerInterface
8
{
9
    /**
10
     * @var \Closure|string
11
     */
12
    private $function;
13
14
    public function __construct($function)
15
    {
16
        if (!is_callable($function) && !($function instanceof \Closure)) {
17
            throw new InvalidCallableTypeException(
18
                sprintf("Parameter 1 of %s must be a valid callback or exist function name.", __METHOD__)
19
            );
20
        }
21
22
        $this->function = $function;
0 ignored issues
show
Documentation Bug introduced by
It seems like $function of type callable is incompatible with the declared type object<Closure>|string of property $function.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function invoke()
29
    {
30
        return call_user_func_array($this->function, func_get_args());
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function invokeWithArgs($args)
37
    {
38
        if (!is_array($args)) {
39
            throw new \InvalidArgumentException(
40
                sprintf("Parameter 1 of %s must be an array of required function arguments.", __METHOD__)
41
            );
42
        }
43
44
        return call_user_func_array($this->function, $args);
45
    }
46
}
47