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
06:11
created

SyncQueue   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A enqueue() 0 21 2
A dequeue() 0 7 1
A peek() 0 7 1
A count() 0 7 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\Exception\InvalidOperationException;
11
use Bernard\Router;
12
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
13
14
class SyncQueue extends AbstractQueue
15
{
16
    /**
17
     * @var EventDispatcherInterface
18
     */
19
    protected $dispatcher;
20
21
    /**
22
     * @var Router
23
     */
24
    protected $router;
25
26
    public function __construct($name, EventDispatcherInterface $dispatcher, Router $router)
27
    {
28
        parent::__construct($name);
29
        $this->dispatcher = $dispatcher;
30
        $this->router = $router;
31
    }
32
33
    /**
34
     * Copy-pasted from Consumer::invoke() and modified
35
     * @param Envelope $envelope
36
     * @throws \Exception
37
     * @throws \Throwable
38
     */
39
    public function enqueue(Envelope $envelope)
40
    {
41
        $this->errorIfClosed();
42
43
        $queue = $this;
44
        try {
45
            $this->dispatcher->dispatch(BernardEvents::PING, new PingEvent($queue));
46
            $this->dispatcher->dispatch(BernardEvents::INVOKE, new EnvelopeEvent($envelope, $queue));
47
48
            // for 5.3 support where a function name is not a callable
49
            call_user_func($this->router->map($envelope), $envelope->getMessage());
50
51
            // We successfully processed the message.
52
            $queue->acknowledge($envelope);
53
54
            $this->dispatcher->dispatch(BernardEvents::ACKNOWLEDGE, new EnvelopeEvent($envelope, $queue));
55
        } 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...
56
            $this->dispatcher->dispatch(BernardEvents::REJECT, new RejectEnvelopeEvent($envelope, $queue, $e));
57
            throw $e;
58
        }
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function dequeue()
65
    {
66
        $this->errorIfClosed();
67
68
        // Sync queue is always empty
69
        return;
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75
    public function peek($index = 0, $limit = 20)
76
    {
77
        $this->errorIfClosed();
78
79
        // Sync queue is always empty
80
        return [];
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function count()
87
    {
88
        $this->errorIfClosed();
89
90
        // Sync queue is always empty
91
        return 0;
92
    }
93
94
}