PolicyManager   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 1
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
 * Policy manager, create, retrieve, delete
8
 *
9
 * @author Ulrich
10
 * @package Metfan\RabbitSetup\Manager\RabbitMq
11
 */
12
class PolicyManager extends BaseManager
13
{
14
15
    /**
16
     * Create element in RabbitMQ
17
     *
18
     * @param $name
19
     * @param array $options
20
     * @return void
21
     */
22
    public function create($name, array $options)
23
    {
24
        $this->client->query(
25
            ClientInterface::METHOD_PUT,
26
            sprintf('/api/policies/%s/%s', $this->vhost, $name),
27
            $options);
28
        $this->logger->info(sprintf('Create poilicy: <info>%s</info>', $name));
29
    }
30
31
    /**
32
     * Get all element of that type in vhost or in RabbitMQ if vhost = null
33
     *
34
     * @param null $vhost
35
     * @return array
36
     */
37
    public function getAll($vhost = null)
38
    {
39
        return $this->findAllElements('/api/policies', $vhost);
40
    }
41
42
    /**
43
     * delete an element on RabbitMQ
44
     *
45
     * @param $vhost
46
     * @param $name
47
     * @return mixed
48
     */
49
    public function delete($vhost, $name)
50
    {
51
        return $this->deleteElement('/api/policies', $vhost, $name, 'policy');
52
    }
53
}
54