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

DoctrineConnectionCheck::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 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