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.
Completed
Pull Request — master (#302)
by Nikolay
02:13
created

SyncQueue::enqueue()   A

Complexity

Conditions 2
Paths 6

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 2
eloc 12
nc 6
nop 1
1
<?php
2
3
namespace Bernard\Queue;
4
5
use Bernard\BernardEvents;
6
use Bernard\Envelope;
7
use Bernard\Event\EnvelopeEvent;
8
use Bernard\Event\PingEvent;
9
use Bernard\Event\RejectEnvelopeEvent;
10
use Bernard\Router;
11
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
12
13
class SyncQueue extends AbstractQueue
14
{
15
    /**
16
     * @var EventDispatcherInterface
17
     */
18
    protected $dispatcher;
19
20
    /**
21
     * @var Router
22
     */
23
    protected $router;
24
25
    public function __construct($name, EventDispatcherInterface $dispatcher, Router $router)
26
    {
27
        parent::__construct($name);
28
        $this->dispatcher = $dispatcher;
29
        $this->router = $router;
30
    }
31
32
    /**
33
     * Copy-pasted from Consumer::invoke() and modified
34
     * @param Envelope $envelope
35
     * @throws \Exception
36
     * @throws \Throwable
37
     */
38
    public function enqueue(Envelope $envelope)
39
    {
40
        $this->errorIfClosed();
41
42
        $queue = $this;
43
        try {
44
            $this->dispatcher->dispatch(BernardEvents::PING, new PingEvent($queue));
45
            $this->dispatcher->dispatch(BernardEvents::INVOKE, new EnvelopeEvent($envelope, $queue));
46
47
            // for 5.3 support where a function name is not a callable
48
            call_user_func($this->router->map($envelope), $envelope->getMessage());
49
50
            // We successfully processed the message.
51
            $queue->acknowledge($envelope);
52
53
            $this->dispatcher->dispatch(BernardEvents::ACKNOWLEDGE, new EnvelopeEvent($envelope, $queue));
54
        } catch (\Throwable $e) {
0 ignored issues
show
Bug introduced by
The class Throwable does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
55
            $this->dispatcher->dispatch(BernardEvents::REJECT, new RejectEnvelopeEvent($envelope, $queue, $e));
56
            throw $e;
57
        }
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function dequeue()
64
    {
65
        $this->errorIfClosed();
66
67
        // Sync queue is always empty
68
        return;
69
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74
    public function peek($index = 0, $limit = 20)
75
    {
76
        $this->errorIfClosed();
77
78
        // Sync queue is always empty
79
        return [];
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85
    public function count()
86
    {
87
        $this->errorIfClosed();
88
89
        // Sync queue is always empty
90
        return 0;
91
    }
92
93
}