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.

MethodInvoker::invoke()   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
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace TaskQueue\Invoker;
4
5
use DependencyInjection\Container;
6
use TaskQueue\Invoker\Exception\ArrayPairLengthAwareException;
7
use TaskQueue\Invoker\Exception\ClassInstanceException;
8
use TaskQueue\Invoker\Exception\ClassMethodException;
9
10
class MethodInvoker implements InvokerInterface
11
{
12
    /**
13
     * @var array
14
     */
15
    private $method;
16
17
    public function __construct($args)
18
    {
19
        if (!is_array($args)) {
20
            throw new \InvalidArgumentException(
21
                sprintf("Parameter 1 of %s must be an array.", __METHOD__)
22
            );
23
        }
24
25
        if (sizeof($args) !== 2) {
26
            throw new ArrayPairLengthAwareException(
27
                sprintf("Parameter 1 of %s must be an array with length === 2.", __METHOD__)
28
            );
29
        }
30
31
        if (!isset($args['instance'])) {
32
            throw new ClassInstanceException("\$args index key 'instance' must exists.");
33
        }
34
35
        if (!isset($args['method'])) {
36
            throw new ClassMethodException("\$args index key 'method' must exists.");
37
        }
38
39
        $args['instance'] = (!is_object($args['instance'])
40
            ? (class_exists($args['instance'])
41
                ? (new Container)->make($args['instance'])
42
                : null)
43
            : $args['instance']);
44
45
        $this->method = $args;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function invoke()
52
    {
53
        return call_user_func_array(
54
            [$this->method['instance'], $this->method['method']], func_get_args()
55
        );
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function invokeWithArgs($args)
62
    {
63
        if (!is_array($args)) {
64
            throw new \InvalidArgumentException(
65
                sprintf("Parameter 1 of %s must be an array.", __METHOD__)
66
            );
67
        }
68
69
        return call_user_func_array(
70
            [$this->method['instance'], $this->method['method']], $args
71
        );
72
    }
73
}
74