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.

TaskQueue::add()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
namespace TaskQueue;
4
5
use TaskQueue\Invoker\InvokerInterface;
6
7
class TaskQueue implements TaskQueueInterface
8
{
9
    /**
10
     * @var array
11
     */
12
    private $tasks = [];
13
14
    /**
15
     * Add callbacks or \Closure into task queueing stack.
16
     *
17
     * @param InvokerInterface $invoker
18
     * @param array $taskArgs The callback or Closure arguments.
19
     * @return TaskQueueInterface
20
     */
21
    public function add(InvokerInterface $invoker, $taskArgs = [])
22
    {
23
        $taskArgs = (is_array($taskArgs) ? $taskArgs : array_slice(func_get_args(), 1));
24
25
        array_unshift($this->tasks, compact('invoker', 'taskArgs'));
26
27
        return $this;
28
    }
29
30
    /**
31
     * Invoke all of pending task in the task queueing stack.
32
     *
33
     * @return void
34
     */
35
    public function run()
36
    {
37
        while ($eachTasks = array_shift($this->tasks)) {
38
            $eachTasks['invoker']->invokeWithArgs($eachTasks['taskArgs']);
39
        }
40
    }
41
}
42