Database   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A call() 0 14 3
1
<?php
2
namespace Health\Checks\Servers;
3
4
use DB;
5
use Health\Checks\BaseCheck;
6
use Health\Checks\HealthCheckInterface;
7
8
/**
9
 * Database Check
10
 */
11
class Database extends BaseCheck implements HealthCheckInterface
12
{
13
14
    /**
15
     *
16
     * {@inheritdoc}
17
     * @see \Health\Checks\HealthCheckInterface::call()
18
     */
19
    public function call()
20
    {
21
        $builder = $this->getBuilder();
22
23
        try {
24
            DB::connection()->getPdo();
25
            if (! DB::connection()->getDatabaseName()) {
26
                $builder->down()->withData("error", "Could not find the database.");
27
            }
28
        } catch (\Exception $e) {
29
            $builder->down()->withData("error", "Could not open connection to database server.");
30
        }
31
32
        return $builder->build();
33
    }
34
}
35