ConfigExpertManager::manageConfig()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

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 2
eloc 4
nc 2
nop 1
1
<?php
2
namespace Metfan\RabbitSetup\Manager\Command;
3
4
use Metfan\RabbitSetup\Http\ClientPool;
5
use Metfan\RabbitSetup\Manager\RabbitMq\VhostManager;
6
7
/**
8
 * Manager of rsetup:config:expert Command
9
 *
10
 * @author Ulrich
11
 * @package Metfan\RabbitSetup\Manager\Command
12
 */
13
class ConfigExpertManager
14
{
15
    /**
16
     * @var ClientPool
17
     */
18
    private $clientPool;
19
20
    /**
21
     * @var VhostManager
22
     */
23
    private $vhostManager;
24
25
    public function __construct(ClientPool $clientPool, VhostManager $vhostManager)
26
    {
27
        $this->clientPool = $clientPool;
28
        $this->vhostManager = $vhostManager;
29
    }
30
31
    /**
32
     * Check config with option resolver.
33
     * Apply each vhost config with VhostManager
34
     *
35
     * @param array $config
36
     */
37
    public function manageConfig(array $config)
38
    {
39
        $this->clientPool->setConnections($config['connections']);
40
41
        foreach ($config['vhosts'] as $name => $vhostConfig) {
42
            $this->vhostManager->processVhost($name, $vhostConfig);
43
        }
44
    }
45
}
46