DoctrineConnectionCheck   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 28
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkStatus() 0 9 2
A __construct() 0 4 1
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->getNativeConnection();
32
        } catch (\Throwable $e) {
33
            $result->setError($e->getMessage());
34
        }
35
        return $result;
36
    }
37
}
38