Completed
Push — v2 ( 926424...fe16f7 )
by Faouzi
10s
created

EtnaConfig   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 71
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 38 1
A register() 0 23 1
1
<?php
2
3
namespace TestRabbitMq;
4
5
use Pimple\Container;
6
use Pimple\ServiceProviderInterface;
7
8
use ETNA\Silex\Provider\Config as ETNAConf;
9
use ETNA\Silex\Provider\RabbitMQ\RabbitConfig;
10
use TestRabbitMq\Consumers\ConsumerA;
11
12
class EtnaConfig implements ServiceProviderInterface
13
{
14
    private $rabbitmq_config;
15
16
    public function __construct()
17
    {
18
        $this->rabbitmq_config = [
19
            "exchanges" => [
20
                "etna" => [
21
                    "name"        => "etna",
22
                    "channel"     => "default",
23
                    "type"        => "direct",
24
                    "passive"     => false,
25
                    "durable"     => true,
26
                    "exclusive"   => false,
27
                    "auto_delete" => false,
28
                ],
29
            ],
30
            "queues" => [
31
                "queue_a" => [
32
                    "name"        => "queue_a",
33
                    "passive"     => false,
34
                    "durable"     => true,
35
                    "exclusive"   => false,
36
                    "auto_delete" => false,
37
                    "exchange"    => "etna",
38
                    "routing.key" => "queue_a",
39
                    "channel"     => "default",
40
                ],
41
                "queue_b" => [
42
                    "name"        => "queue_b",
43
                    "passive"     => false,
44
                    "durable"     => true,
45
                    "exclusive"   => false,
46
                    "auto_delete" => false,
47
                    "exchange"    => "etna",
48
                    "routing.key" => "queue_b",
49
                    "channel"     => "default",
50
                ]
51
            ]
52
        ];
53
    }
54
55
    /**
56
     *
57
     * @{inherit doc}
58
     */
59
    public function register(Container $app)
60
    {
61
        $app["rmq_producers"] = [
62
            'producer_a' => [
63
                'connection'       => 'default',
64
                'exchange_options' => $this->rabbitmq_config['exchanges']['etna'],
65
                'queue_options'    => ['name' => 'queue_a', 'routing_keys' => ['queue_a']]
66
            ]
67
        ];
68
69
        $app['ConsumerA'] = new ConsumerA();
70
71
        $app["rmq_consumers"] = [
72
            'consumer_a' => [
73
                'connection'        => 'default',
74
                'exchange_options'  => $this->rabbitmq_config['exchanges']['etna'],
75
                'queue_options'     => ['name' => 'queue_a', 'routing_keys' => ['queue_a']],
76
                'callback'          => 'ConsumerA'
77
            ]
78
        ];
79
80
        $app->register(new RabbitConfig($this->rabbitmq_config));
81
    }
82
}
83