ExchangeManager   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 12 2
A getAll() 0 4 1
A delete() 0 4 1
1
<?php
2
namespace Metfan\RabbitSetup\Manager\RabbitMq;
3
4
use Metfan\RabbitSetup\Http\ClientInterface;
5
6
/**
7
 * Exchange manager, create, retrieve, delete
8
 *
9
 * @author Ulrich
10
 * @package Metfan\RabbitSetup\Manager
11
 */
12
class ExchangeManager extends BaseManager
13
{
14
    /**
15
     * Create an exchange
16
     *
17
     * @param string $exchangeName
18
     * @param array $options
19
     * @return void
20
     */
21
    public function create($exchangeName, array $options)
22
    {
23
        if (empty($options['arguments'])) {
24
            unset($options['arguments']);
25
        }
26
27
        $this->client->query(
28
            ClientInterface::METHOD_PUT,
29
            sprintf('/api/exchanges/%s/%s', $this->vhost, $exchangeName),
30
            $options);
31
        $this->logger->info(sprintf('Create exchange: <info>%s</info>', $exchangeName));
32
    }
33
34
    /**
35
     * Get all exchanges from a vhost or all exchange in your rabbitmq
36
     *
37
     * @param null $vhost
38
     * @return mixed
39
     */
40
    public function getAll($vhost = null)
41
    {
42
        return $this->findAllElements('/api/exchanges', $vhost);
43
    }
44
45
    /**
46
     * Delete an exchange from a vhost
47
     *
48
     * @param $vhost
49
     * @param $name
50
     * @return mixed
51
     */
52
    public function delete($vhost, $name)
53
    {
54
        return $this->deleteElement('/api/exchanges', $vhost, $name, 'exchange');
55
    }
56
}
57