DoctrineDbalCollection::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 13

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 13
loc 13
ccs 8
cts 8
cp 1
rs 9.8333
c 0
b 0
f 0
cc 3
nc 4
nop 2
crap 3
1
<?php
2
3
namespace Liip\MonitorBundle\Check;
4
5
use Doctrine\Persistence\ConnectionRegistry;
6
use Laminas\Diagnostics\Check\CheckCollectionInterface;
7
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11 View Code Duplication
class DoctrineDbalCollection implements CheckCollectionInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
12
{
13
    private $checks = [];
14
15 4
    public function __construct(ConnectionRegistry $manager, $connections)
16
    {
17 4
        if (!is_array($connections)) {
18 1
            $connections = [$connections];
19
        }
20
21 4
        foreach ($connections as $connection) {
22 4
            $check = new DoctrineDbal($manager, $connection);
23 4
            $check->setLabel(sprintf('Doctrine DBAL "%s" connection', $connection));
24
25 4
            $this->checks[sprintf('doctrine_dbal_%s_connection', $connection)] = $check;
26
        }
27 4
    }
28
29 4
    public function getChecks()
30
    {
31 4
        return $this->checks;
32
    }
33
}
34