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   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 4
dl 0
loc 64
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A invoke() 0 6 1
A invokeWithArgs() 0 12 2
C __construct() 0 30 7
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