door: don't require default row in database
This commit is contained in:
@@ -70,9 +70,9 @@ class Door {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{time: DateTimeImmutable, open: bool}
|
||||
* @return ?array{time: DateTimeImmutable, open: bool}
|
||||
*/
|
||||
public function getCurrent(): array {
|
||||
public function getCurrent(): ?array {
|
||||
$query = '
|
||||
SELECT
|
||||
time,
|
||||
@@ -85,6 +85,10 @@ class Door {
|
||||
$statement->execute();
|
||||
$row = $statement->fetch();
|
||||
|
||||
if (!$row) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'time' => (new DateTimeImmutable)->setTimestamp((int) $row['time']),
|
||||
'open' => (bool) $row['open'],
|
||||
|
||||
Reference in New Issue
Block a user