Completed
Push — master ( 3ab99e...f52567 )
by Bret R.
04:11
created

DoctrineConnectionCheck   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A check() 0 11 2
1
<?php
2
3
namespace BretRZaun\StatusPage\Check;
4
5
use BretRZaun\StatusPage\Result;
6
7
class DoctrineConnectionCheck extends AbstractCheck
8
{
9
10
    /**
11
     * @var \Doctrine\DBAL\Connection
12
     */
13
    protected $db;
14
15
    public function __construct($label, \Doctrine\DBAL\Connection $db)
16
    {
17
        parent::__construct($label);
18
        $this->db = $db;
19
    }
20
21
    /**
22
     * Check Doctrine connection
23
     *
24
     * @return Result
25
     */
26
    public function check()
27
    {
28
        $result = new Result($this->label);
29
        try {
30
            $this->db->connect();
31
        } catch (\Exception $e) {
32
            $result->setSuccess(false);
33
            $result->setError($e->getMessage());
34
        }
35
        return $result;
36
    }
37
}
38