pot/author/project/system/models/traits/status.php

46 lines
815 B
PHP
Raw Permalink Normal View History

2024-01-11 04:35:40 +07:00
<?php
declare(strict_types=1);
2024-01-11 05:38:30 +07:00
namespace ${REPO_OWNER}\${REPO_NAME}\models\traits;
2024-01-11 04:35:40 +07:00
// Built-in libraries
use exception;
/**
* Trait fo initialization of a status
*
2024-01-11 05:38:30 +07:00
* @package ${REPO_OWNER}\${REPO_NAME}\models\traits
2024-01-11 04:35:40 +07:00
*
2024-01-11 05:38:30 +07:00
* @author ${REPO_OWNER} < mail >
2024-01-11 04:35:40 +07:00
*/
trait status
{
/**
* Initialize of a status
*
* @param array &$errors Registry of errors
*
* @return ?bool Status, if they are found
*/
public function status(array &$errors = []): ?bool
{
try {
// Read from ArangoDB and exit (success)
return $this->document->active ?? false;
} catch (exception $e) {
// Write to the registry of errors
$errors[] = [
'text' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'stack' => $e->getTrace()
];
}
// Exit (fail)
return null;
}
}