-
Notifications
You must be signed in to change notification settings - Fork 1
/
ReadUserCheck.php
47 lines (40 loc) · 1.15 KB
/
ReadUserCheck.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types=1);
namespace App\Repository\DatabaseCheck;
use App\ApplicationHealth\DependencyCheck\DatabaseCheck\DatabaseUserCheck;
use Cushon\HealthBundle\ApplicationHealth\HealthReport\DependencyStatus;
use Cushon\HealthBundle\ApplicationHealth\HealthReport\DependencyStatus\SimpleStatus;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception;
final class ReadUserCheck implements DatabaseUserCheck
{
/**
* @var Connection
*/
private Connection $connection;
/**
* @param Connection $readConnection
*/
public function __construct(Connection $readConnection)
{
$this->connection = $readConnection;
}
/**
* @inheritDoc
*/
public function checkUser(): DependencyStatus
{
$healthy = false;
try {
$this->connection->createQueryBuilder()
->select('last_checked')
->from('health')
->executeQuery();
$healthy = true;
$info = null;
} catch (Exception $e) {
$info = $e->getMessage();
}
return new SimpleStatus('DB read user', $healthy, $info);
}
}