RabbitMQCollection::getChecks()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Liip\MonitorBundle\Check;
4
5
use Laminas\Diagnostics\Check\CheckCollectionInterface;
6
use Laminas\Diagnostics\Check\RabbitMQ;
7
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
class RabbitMQCollection implements CheckCollectionInterface
12
{
13
    private $checks = [];
14
15 1
    public function __construct(array $configs)
16
    {
17 1
        foreach ($configs as $name => $config) {
18 1
            if (isset($config['dsn'])) {
19
                $config = array_merge($config, parse_url($config['dsn']));
20 View Code Duplication
                if (isset($config['pass'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
                    $config['password'] = $config['pass'];
22
                    // Cleanup
23
                    unset($config['pass']);
24
                }
25
                if (isset($config['path'])) {
26
                    $config['vhost'] = urldecode(substr($config['path'], 1));
27
                    // Cleanup
28
                    unset($config['path']);
29
                }
30
            }
31
32 1
            $check = new RabbitMQ($config['host'], $config['port'], $config['user'], $config['password'], $config['vhost']);
33 1
            $check->setLabel(sprintf('Rabbit MQ "%s"', $name));
34
35 1
            $this->checks[sprintf('rabbit_mq_%s', $name)] = $check;
36
        }
37 1
    }
38
39 1
    public function getChecks()
40
    {
41 1
        return $this->checks;
42
    }
43
}
44