Completed
Push — master ( 0aa8ac...a01137 )
by Bret R.
01:24
created

DoctrineConnectionCheck::checkStatus()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

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