Producer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 28
ccs 13
cts 13
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A __invoke() 0 14 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\AMQPBundle\Producer;
5
6
use Innmind\AMQPBundle\Producer as ProducerInterface;
7
use Innmind\AMQP\{
8
    Client,
9
    Model\Basic\Publish,
10
    Model\Basic\Message
11
};
12
13
final class Producer implements ProducerInterface
14
{
15
    private $client;
16
    private $exchange;
17
18 2
    public function __construct(
19
        Client $client,
20
        string $exchange
21
    ) {
22 2
        $this->client = $client;
23 2
        $this->exchange = $exchange;
24 2
    }
25
26 2
    public function __invoke(Message $message, string $routingKey = null): ProducerInterface
27
    {
28
        $this
29 2
            ->client
30 2
            ->channel()
31 2
            ->basic()
32 2
            ->publish(
33 2
                (new Publish($message))
34 2
                    ->to($this->exchange)
35 2
                    ->withRoutingKey($routingKey ?? '')
36
            );
37
38 2
        return $this;
39
    }
40
}
41