Completed
Push — master ( 0aa8ac...a01137 )
by Bret R.
01:24
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 checkStatus() 0 11 2
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