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

60 lines
1.2 KiB
PHP
Raw 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
// Files of the project
use ${REPO_OWNER}\${REPO_NAME}\models\traits\document as document_trait,
${REPO_OWNER}\${REPO_NAME}\models\interfaces\document as document_interface;
2024-01-11 04:35:40 +07:00
// Built-in libraries
use exception;
/**
* Status (DUMB SHIT)
*
* Trait for initialization of a status
*
* @uses document_trait
* @uses document_interface
*
2024-12-15 22:16:01 +07:00
* @method bool|null status(array &$$errors) Check document by its status
2024-01-11 04:35:40 +07:00
*
2024-01-11 05:38:30 +07:00
* @package ${REPO_OWNER}\${REPO_NAME}\models\traits
2024-01-11 04:35:40 +07:00
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author ${REPO_OWNER} <mail@domain.zone>
2024-01-11 04:35:40 +07:00
*/
trait status
{
/**
* Status
*
* Check document by its status
2024-01-11 04:35:40 +07:00
*
2024-12-15 22:16:01 +07:00
* @param array &$$errors Registry of errors
2024-01-11 04:35:40 +07:00
*
* @return ?bool Status, if found
2024-01-11 04:35:40 +07:00
*/
2024-12-15 22:16:01 +07:00
public function status(array &$$errors = []): ?bool
2024-01-11 04:35:40 +07:00
{
try {
// Read from ArangoDB and exit (success)
2024-12-15 22:16:01 +07:00
return $$this->document->active ?? false;
} catch (exception $$e) {
// Writing to the registry of errors
2024-12-15 22:16:01 +07:00
$$errors[] = [
'text' => $$e->getMessage(),
'file' => $$e->getFile(),
'line' => $$e->getLine(),
'stack' => $$e->getTrace()
2024-01-11 04:35:40 +07:00
];
}
// Exit (fail)
return null;
}
}