Compare commits
No commits in common. "stable" and "0.1.0" have entirely different histories.
|
@ -1,3 +1 @@
|
|||
vendor
|
||||
composer.lock
|
||||
!.gitignore
|
||||
|
|
11
LICENSE
11
LICENSE
|
@ -1,11 +0,0 @@
|
|||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
@ -1,3 +0,0 @@
|
|||
# PHP 8.3 Framework for working with ArangoDB
|
||||
|
||||
🤟 Very simple and flexible, easy to scale and integrate
|
|
@ -1,11 +1,10 @@
|
|||
{
|
||||
"name": "mirzaev/arangodb",
|
||||
"description": "Simple PHP-framework for ArangoDB",
|
||||
"readme": "README.md",
|
||||
"description": "Реализация управления хранилищем данных ArangoDB",
|
||||
"keywords": [
|
||||
"ArangoDB"
|
||||
],
|
||||
"type": "framework",
|
||||
"type": "library",
|
||||
"license": "WTFPL",
|
||||
"homepage": "https://git.hood.su/mirzaev/arangodb",
|
||||
"authors": [
|
||||
|
@ -16,20 +15,9 @@
|
|||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"email": "arsen@mirzaev.sexy",
|
||||
"wiki": "https://git.mirzaev.sexy/mirzaev/arangodb/manual",
|
||||
"issues": "https://git.mirzaev.sexy/mirzaev/arangodb/issues"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"type": "funding",
|
||||
"url": "https://fund.mirzaev.sexy"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"triagens/arangodb": "~3.8"
|
||||
"php": "^8.0.0",
|
||||
"triagens/arangodb": "~3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.3.3"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,201 +4,80 @@ declare(strict_types=1);
|
|||
|
||||
namespace mirzaev\arangodb;
|
||||
|
||||
// Files of the project
|
||||
use mirzaev\arangodb\connection,
|
||||
mirzaev\arangodb\terminal,
|
||||
mirzaev\arangodb\enumerations\collection\type;
|
||||
use mirzaev\arangodb\terminal;
|
||||
|
||||
// Library for ArangoDB
|
||||
use ArangoDBClient\Statement as _statement,
|
||||
ArangoDBClient\Document as _document,
|
||||
ArangoDBClient\CollectionHandler as _collection_handler,
|
||||
ArangoDBClient\Cursor as cursor;
|
||||
|
||||
// Built-in libraries
|
||||
use exception;
|
||||
use ArangoDBClient\Connection as _connection;
|
||||
use ArangoDBClient\Collection as _collection;
|
||||
use ArangoDBClient\CollectionHandler as _collection_handler;
|
||||
|
||||
/**
|
||||
* Collection
|
||||
* Коллекция
|
||||
*
|
||||
* @package mirzaev\arangodb
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
class collection
|
||||
{
|
||||
/**
|
||||
* Initialize a collection
|
||||
* Инициализация
|
||||
*
|
||||
* @param string $collection Name of the collection
|
||||
* @param type $type Type of the collection
|
||||
* @param ?terminal $terminal Инстанция терминала
|
||||
* @param array &$errors Registry of errors
|
||||
* @param _connection $connection Инстанция соединения
|
||||
* @param string $name Название
|
||||
* @param bool $edge Это ребро? (иначе: вершина)
|
||||
*
|
||||
* @return string|null Identifier of the collection
|
||||
* @return string|null Идентификатор
|
||||
*/
|
||||
public static function initialize(string $name, type $type = type::document, ?terminal $terminal = null, array &$errors = []): ?string
|
||||
public static function init(_connection $connection, string $name, bool $edge = false): ?string
|
||||
{
|
||||
try {
|
||||
// Инициализация
|
||||
$collections = new _collection_handler(connection::$session);
|
||||
$collections = new _collection_handler($connection);
|
||||
|
||||
if (!$collections->has($name)) {
|
||||
// Не найдана коллекция
|
||||
// Коллекция не найдена
|
||||
|
||||
// Запись в вывод
|
||||
if ($terminal instanceof terminal) $terminal::write("Not found $type collection: $name");
|
||||
terminal::write("Коллекция \"$name\" не найдена");
|
||||
|
||||
// Инициализация
|
||||
$collection = new _collection();
|
||||
|
||||
// Настройка
|
||||
$collection->setName($name);
|
||||
$collection->setType($edge ? 'edge' : 'document');
|
||||
|
||||
// Запись коллекции на сервер и его ответ в буфер возврата
|
||||
$id = $collections->create($name, ['type' => $type->code()]);
|
||||
$id = $collections->create($name);
|
||||
|
||||
if ($collections->has($name)) {
|
||||
// Коллекция найдена (записана)
|
||||
|
||||
// Запись в вывод
|
||||
if ($terminal instanceof terminal) $terminal::write("Created $type collection: $name");
|
||||
terminal::write("Создана коллекция \"$name\"");
|
||||
|
||||
// Возврат идентификатора коллекции
|
||||
return $id;
|
||||
}
|
||||
} else {
|
||||
// Найдена коллекция
|
||||
|
||||
// Возврат идентификатора коллекции
|
||||
return $name;
|
||||
}
|
||||
} catch (exception $e) {
|
||||
// Writing to registry of errors
|
||||
$errors[] = [
|
||||
'text' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack' => $e->getTrace()
|
||||
];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute
|
||||
* Поиск
|
||||
*
|
||||
* @param string $query Query (AQL)
|
||||
* @param array $parameters Binded parameters for placeholders [placholder => parameter]
|
||||
* @param bool $flat Not implement record?
|
||||
* @param array &$errors Registry of errors
|
||||
* @param _connection $connection Соединение
|
||||
* @param string $collection Название
|
||||
* @param array $condition Условия
|
||||
*
|
||||
* @return _document|array|string|int|null Instance of the document
|
||||
* @return array|null Коллекция, если найдена
|
||||
*/
|
||||
public static function execute(string $query, array $parameters = [], bool $flat = false, array &$errors = []): _document|string|array|int|null
|
||||
public static function search(_connection $connection, string $name, array $condition): ?array
|
||||
{
|
||||
try {
|
||||
// Statement instance initialization
|
||||
$instance = new _statement(
|
||||
connection::$session,
|
||||
[
|
||||
'query' => $query,
|
||||
'batchSize' => 1000,
|
||||
'sanitize' => true,
|
||||
cursor::ENTRY_FLAT => $flat
|
||||
]
|
||||
);
|
||||
// Инициализация
|
||||
$collections = new _collection_handler($connection);
|
||||
|
||||
// Binds application
|
||||
$instance->bind($parameters);
|
||||
if ($collections->has($name)) {
|
||||
// Коллекция найдена
|
||||
|
||||
// Sending the request
|
||||
$response = $instance->execute();
|
||||
|
||||
// Инициализация буфера вывода
|
||||
$buffer = [];
|
||||
|
||||
foreach ($response->getAll() as $key => $value) {
|
||||
$buffer[$key] = $value;
|
||||
return $collections->byExample($name, $condition)->getAll();
|
||||
}
|
||||
|
||||
// Exit (success)
|
||||
return is_array($buffer) && count($buffer) > 1 ? $buffer : $buffer[0] ?? null;
|
||||
} catch (exception $e) {
|
||||
// Writing to registry of errors
|
||||
$errors[] = [
|
||||
'text' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack' => $e->getTrace()
|
||||
];
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate
|
||||
*
|
||||
* @param string $name Name of the collection
|
||||
* @param array &$errors Registry of errors
|
||||
*
|
||||
* @return bool Статус выполнения
|
||||
*/
|
||||
public static function truncate(string $collection, array &$errors = []): bool
|
||||
{
|
||||
try {
|
||||
// Initizlizing of the collection handler
|
||||
$collections = new _collection_handler(connection::$session);
|
||||
|
||||
if ($collections->has($collection)) {
|
||||
// Fount the collection
|
||||
|
||||
// Truncate and exit (success)
|
||||
return $collections->truncate($collection);
|
||||
}
|
||||
} catch (exception $e) {
|
||||
// Writing to registry of errors
|
||||
$errors[] = [
|
||||
'text' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack' => $e->getTrace()
|
||||
];
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count documents in ArangoDB
|
||||
*
|
||||
* @param string $collection Name of the collection
|
||||
* @param array &$errors Registry of errors
|
||||
*
|
||||
* @return int|null Amount of documents in ArangoDB
|
||||
*/
|
||||
public static function count(string $collection, array &$errors = []): ?int
|
||||
{
|
||||
try {
|
||||
// Count and exit (success)
|
||||
return static::execute(
|
||||
<<<'AQL'
|
||||
RETURN LENGTH(@@collection)
|
||||
AQL,
|
||||
[
|
||||
'@collection' => $collection
|
||||
]
|
||||
);
|
||||
} catch (exception $e) {
|
||||
// Writing to registry of errors
|
||||
$errors[] = [
|
||||
'text' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack' => $e->getTrace()
|
||||
];
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,21 +4,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace mirzaev\arangodb;
|
||||
|
||||
// Library for ArangoDB
|
||||
use ArangoDBClient\Connection as _connection,
|
||||
ArangoDBClient\Exception as _exception,
|
||||
ArangoDBClient\UpdatePolicy as _update,
|
||||
ArangoDBClient\ConnectionOptions as _options;
|
||||
use ArangoDBClient\Connection as _connection;
|
||||
use ArangoDBClient\Exception as _exception;
|
||||
use ArangoDBClient\UpdatePolicy as _update;
|
||||
use ArangoDBClient\ConnectionOptions as _options;
|
||||
|
||||
// Built-in libraries
|
||||
use exception;
|
||||
|
||||
/**
|
||||
* Connection
|
||||
* Подключение
|
||||
*
|
||||
* @package mirzaev\arangodb
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class connection
|
||||
|
@ -86,14 +82,12 @@ final class connection
|
|||
/**
|
||||
* Сессия соединения
|
||||
*/
|
||||
public static _connection $session;
|
||||
protected _connection $session;
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @param array $settings Настройки
|
||||
*
|
||||
* @todo ПЕРЕДЕЛАТЬ ПОЛНОСТЬЮ
|
||||
*/
|
||||
public function __construct(array $settings = null)
|
||||
{
|
||||
|
@ -118,7 +112,7 @@ final class connection
|
|||
}
|
||||
|
||||
// Подключение
|
||||
static::$session = new _connection([
|
||||
$this->session = new _connection([
|
||||
_options::OPTION_ENDPOINT => $this->adress,
|
||||
_options::OPTION_DATABASE => $this->storage,
|
||||
_options::OPTION_AUTH_TYPE => $this->auth,
|
||||
|
@ -144,16 +138,15 @@ final class connection
|
|||
match ($name) {
|
||||
'adress', 'endpoint' => $this->adress = $value ?? throw new exception("Свойство \"$name\" не может быть пустым", 500),
|
||||
'storage', 'database', 'db' => $this->storage = $value ?? throw new exception("Свойство \"$name\" не может быть пустым", 500),
|
||||
'auth' => !$value ?: $this->auth = $value,
|
||||
'name' => !$value ?: $this->name = $value,
|
||||
'password' => !$value ?: $this->password = $value,
|
||||
'connection' => !$value ?: $this->connection = $value,
|
||||
'timeout_connect' => !$value ?: $this->timeout_connect = $value,
|
||||
'timeout_request' => !$value ?: $this->timeout_request = $value,
|
||||
'reconnect' => !$value ?: $this->reconnect = $value,
|
||||
'create' => !$value ?: $this->create = $value,
|
||||
'update', 'policy' => !$value ?: $this->update = $value,
|
||||
'journal' => !$value ?: $this->journal = $value,
|
||||
'auth' => $this->auth = $value,
|
||||
'name' => $this->name = $value,
|
||||
'password' => $this->password = $value,
|
||||
'connection' => $this->connection = $value,
|
||||
'timeout_connect' => $this->timeout_connect = $value,
|
||||
'timeout_request' => $this->timeout_request = $value,
|
||||
'reconnect' => $this->reconnect = $value,
|
||||
'create' => $this->create = $value,
|
||||
'update', 'policy' => $this->update = $value,
|
||||
default => throw new exception("Свойство \"$name\" не найдено", 404)
|
||||
};
|
||||
}
|
||||
|
@ -177,7 +170,7 @@ final class connection
|
|||
'reconnect' => $this->reconnect,
|
||||
'create' => $this->create,
|
||||
'update', 'policy' => $this->update,
|
||||
'journal' => $this->journal,
|
||||
'session' => $this->session,
|
||||
default => throw new exception("Свойство \"$name\" не найдено", 404)
|
||||
};
|
||||
}
|
||||
|
@ -201,7 +194,7 @@ final class connection
|
|||
'reconnect' => isset($this->reconnect),
|
||||
'create' => isset($this->create),
|
||||
'update', 'policy' => isset($this->update),
|
||||
'journal' => isset($this->journal),
|
||||
'session' => isset($this->session),
|
||||
default => throw new exception("Свойство \"$name\" не найдено", 404)
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,63 +4,41 @@ declare(strict_types=1);
|
|||
|
||||
namespace mirzaev\arangodb;
|
||||
|
||||
// Files of the project
|
||||
use mirzaev\arangodb\terminal,
|
||||
mirzaev\arangodb\connection,
|
||||
mirzaev\arangodb\enumerations\collection\type;
|
||||
use mirzaev\arangodb\terminal;
|
||||
|
||||
// Librsry for ArangoDB
|
||||
use ArangoDBClient\Connection as _connection,
|
||||
ArangoDBClient\Document as _document,
|
||||
ArangoDBClient\Edge as _edge,
|
||||
ArangoDBClient\DocumentHandler as _document_handler,
|
||||
ArangoDBClient\EdgeHandler as _edge_handler;
|
||||
|
||||
// Built-in libraries
|
||||
use exception;
|
||||
use ArangoDBClient\Connection as _connection;
|
||||
use ArangoDBClient\Document as _document;
|
||||
use ArangoDBClient\Edge as _edge;
|
||||
use ArangoDBClient\CollectionHandler as _collection_handler;
|
||||
use ArangoDBClient\EdgeHandler as _edge_handler;
|
||||
|
||||
/**
|
||||
* Document
|
||||
*
|
||||
* Handlers of document in ArangoDB
|
||||
* Документ
|
||||
*
|
||||
* @package mirzaev\arangodb
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
class document
|
||||
{
|
||||
/**
|
||||
* Write
|
||||
* Записать
|
||||
*
|
||||
* @param _connection $connection Инстанция соединения
|
||||
* @param string $collection Коллекция
|
||||
* @param ?array $data Данные
|
||||
* @param bool $check Проверка на запись в базу данных
|
||||
* @param ?terminal $terminal Instance of the terminal
|
||||
* @param array &$errors Registry of errors
|
||||
* @param array $data Данные
|
||||
*
|
||||
* @return string|null Идентификатор
|
||||
*
|
||||
* @todo
|
||||
* 1. Bind parameters
|
||||
*/
|
||||
public static function write(
|
||||
string $collection,
|
||||
?array $data = [],
|
||||
bool $check = false,
|
||||
?terminal $terminal = null,
|
||||
array &$errors = []
|
||||
): string|null|false {
|
||||
try {
|
||||
public static function write(_connection $connection, string $collection, array $data): ?string
|
||||
{
|
||||
// Инициализация коллекции
|
||||
collection::initialize($collection, isset($data['_from'], $data['_to']) ? type::edge : type::document);
|
||||
collection::init($connection, $collection, isset($data['_from'], $data['_to']));
|
||||
|
||||
if (isset($data['_from'], $data['_to'])) {
|
||||
// Ребро
|
||||
|
||||
// Инициализация обработчика рёбер
|
||||
$documents = new _edge_handler(connection::$session);
|
||||
$documents = new _edge_handler($connection);
|
||||
|
||||
// Инициализация ребра
|
||||
$document = new _edge();
|
||||
|
@ -75,115 +53,30 @@ class document
|
|||
// Вершина
|
||||
|
||||
// Инициализация обработчика вершин
|
||||
$documents = new _document_handler(connection::$session);
|
||||
$documents = new _collection_handler($connection);
|
||||
|
||||
// Инициализация вершины
|
||||
$document = new _document();
|
||||
}
|
||||
|
||||
// Инициализация даты создания
|
||||
$created = time();
|
||||
|
||||
foreach (['created' => $created, 'updated' => $created] + $data as $key => $value) {
|
||||
// Настройка
|
||||
foreach ($data as $key => $value) {
|
||||
// Перебор параметров
|
||||
|
||||
// Запись в инстанцию документа
|
||||
$document->set($key, $value);
|
||||
}
|
||||
|
||||
// Запись на сервер и его ответ в буфер возврата
|
||||
$id = isset($_from, $_to) ? $documents->saveEdge($collection, $_from, $_to, $document) : $documents->insert($collection, $document);
|
||||
$id = isset($_from, $_to) ? $documents->saveEdge($collection, $_from, $_to, $document) : $documents->save($collection, $document);
|
||||
|
||||
if ($check && $documents->has($collection, $id)) {
|
||||
// Найден записанный документ
|
||||
if ($documents->has($collection, $id)) {
|
||||
// Документ записан
|
||||
|
||||
// Запись в вывод
|
||||
if ($terminal instanceof terminal) $terminal::write("В коллекции \"$collection\" создан документ \"$id\"");
|
||||
} else if ($check) {
|
||||
// Не найден записанный документ
|
||||
|
||||
// Запись в вывод
|
||||
if ($terminal instanceof terminal) $terminal::write("В коллекции \"$collection\" не удалось найти созданный или создать документ");
|
||||
|
||||
return null;
|
||||
}
|
||||
terminal::write("В коллекции \"$collection\" создан документ \"$id\"");
|
||||
|
||||
// Возврат идентификатора коллекции
|
||||
return $id;
|
||||
} catch (exception $e) {
|
||||
// Writing to registry of errors
|
||||
$errors[] = [
|
||||
'text' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack' => $e->getTrace()
|
||||
];
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update
|
||||
*
|
||||
* @param array &$errors Registry of errors
|
||||
* @param _document $document Instance of the document
|
||||
*
|
||||
* @return bool Has the document been updated?
|
||||
*/
|
||||
public static function update(_document $document, array &$errors = []): bool
|
||||
{
|
||||
try {
|
||||
// Initialize the handler of documents
|
||||
$documents = new _document_handler(connection::$session);
|
||||
|
||||
// Writing date of the updating to the updating document
|
||||
$document->set('updated', time());
|
||||
|
||||
// Writing and exit (success)
|
||||
return $documents->update($document);
|
||||
} catch (exception $e) {
|
||||
// Writing to registry of errors
|
||||
$errors[] = [
|
||||
'text' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack' => $e->getTrace()
|
||||
];
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @param _document $document Instance of the document
|
||||
* @param array &$errors Registry of errors
|
||||
*
|
||||
* @return bool Has the document been deleted?
|
||||
*/
|
||||
public static function delete(_document $document, array &$errors = []): bool
|
||||
{
|
||||
try {
|
||||
// Initialize the handler of documents
|
||||
$documents = new _document_handler(connection::$session);
|
||||
|
||||
// Delete abd exit (success)
|
||||
return $documents->remove($document);
|
||||
} catch (exception $e) {
|
||||
// Writing to registry of errors
|
||||
$errors[] = [
|
||||
'text' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack' => $e->getTrace()
|
||||
];
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace mirzaev\arangodb\enumerations\collection;
|
||||
|
||||
// Library for ArangoDB
|
||||
use ArangoDBClient\Collection as _collection;
|
||||
|
||||
/**
|
||||
* Types of collections
|
||||
*
|
||||
* @package mirzaev\arangodb\enumerations\collection
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
enum type
|
||||
{
|
||||
case document;
|
||||
case edge;
|
||||
|
||||
/**
|
||||
* Read code of the type from library for ArangoDB
|
||||
*
|
||||
* @return int Code of the type
|
||||
*/
|
||||
public function code(): int
|
||||
{
|
||||
// Exit (success)
|
||||
return match ($this) {
|
||||
type::document => _collection::TYPE_DOCUMENT,
|
||||
type::edge => _collection::TYPE_EDGE
|
||||
};
|
||||
}
|
||||
}
|
|
@ -4,26 +4,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace mirzaev\arangodb;
|
||||
|
||||
// Built-in libraries
|
||||
use exception;
|
||||
|
||||
/**
|
||||
* Terminal
|
||||
*
|
||||
* lol sorry
|
||||
* i did not want to do this
|
||||
*
|
||||
* @package mirzaev\arangodb
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
class terminal
|
||||
{
|
||||
/**
|
||||
* Префикс
|
||||
*/
|
||||
protected const string PREFIX = 'arangodb';
|
||||
protected const PREFIX = 'arangodb';
|
||||
|
||||
/**
|
||||
* Запись в вывод
|
||||
|
@ -32,6 +18,14 @@ class terminal
|
|||
*/
|
||||
public static function write(string $text): void
|
||||
{
|
||||
echo sprintf("[%s] $text\n", self::PREFIX);
|
||||
echo self::generate_prefix() . ' ' . $text . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Генерация префикса
|
||||
*/
|
||||
public static function generate_prefix(): string
|
||||
{
|
||||
return '[' . self::PREFIX . ']';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue