PolicyManager::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 6
nc 1
nop 2
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