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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 6
dl 0
loc 36
ccs 15
cts 18
cp 0.8333
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A produce() 0 9 2
A dispatch() 0 6 2
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