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
Push — master ( eab0f2...fee417 )
by Jeroen
05:26 queued 10s
created

Producer::dispatch()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 6
cp 0.8333
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2.0185
1
<?php
2
3
namespace Bernard;
4
5
use Bernard\Event\EnvelopeEvent;
6
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
7
8
class Producer
9
{
10
    protected $queues;
11
    protected $dispatcher;
12
13
    /**
14
     * @param QueueFactory             $queues
15
     * @param EventDispatcherInterface $dispatcher
16
     */
17 3
    public function __construct(QueueFactory $queues, EventDispatcherInterface $dispatcher)
18
    {
19 3
        $this->queues = $queues;
20 3
        $this->dispatcher = $dispatcher;
21 3
    }
22
23
    /**
24
     * @param Message     $message
25
     * @param string|null $queueName
26
     */
27 3
    public function produce(Message $message, $queueName = null)
28
    {
29 3
        $queueName = $queueName ?: Util::guessQueue($message);
30
31 3
        $queue = $this->queues->create($queueName);
32 3
        $queue->enqueue($envelope = new Envelope($message));
33
34 3
        $this->dispatch(BernardEvents::PRODUCE, new EnvelopeEvent($envelope, $queue));
35 3
    }
36
37 3
    private function dispatch($eventName, EnvelopeEvent $event)
38
    {
39 3
        $this->dispatcher instanceof \Symfony\Contracts\EventDispatcher\EventDispatcherInterface
40 3
           ? $this->dispatcher->dispatch($event, $eventName)
41 3
           : $this->dispatcher->dispatch($eventName, $event);
42 3
    }
43
}
44