Completed
Push — master ( fee4f6...5610d2 )
by Kevin
02:47 queued 01:31
created

DoctrineDbal   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 36.36%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 26
ccs 4
cts 11
cp 0.3636
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A check() 0 14 2
1
<?php
2
3
namespace Liip\MonitorBundle\Check;
4
5
use Doctrine\Persistence\ConnectionRegistry;
6
use Laminas\Diagnostics\Check\AbstractCheck;
7
use Laminas\Diagnostics\Result\Success;
8
9
class DoctrineDbal extends AbstractCheck
10
{
11
    protected $manager;
12
    protected $connectionName;
13
14 4
    public function __construct(ConnectionRegistry $registry, $connectionName = null)
15
    {
16 4
        $this->manager = $registry;
17 4
        $this->connectionName = $connectionName;
18 4
    }
19
20
    public function check()
21
    {
22
        $connection = $this->manager->getConnection($this->connectionName);
23
        $query = $connection->getDriver()->getDatabasePlatform()->getDummySelectSQL();
24
25
        // after dbal 2.11 fetchOne replace fetchColumn
26
        if (method_exists($connection, 'fetchOne')) {
27
            $connection->fetchOne($query);
28
        } else {
29
            $connection->fetchColumn($query);
30
        }
31
32
        return new Success();
33
    }
34
}
35