Initial commit

This commit is contained in:
2025-04-10 22:19:38 +07:00
commit b395a10d28
141 changed files with 1098 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace mirzaev\luchikki\models;
// Framework for PHP
use mirzaev\minimal\model,
mirzaev\minimal\http\enumerations\status;
// Built-in libraries
use exception;
/**
* Models core
*
* @package mirzaev\luchikki\models
*
* @method void __construct() Constructor
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
* @author mirzaev <mail@domain.zone>
*/
class core extends model
{
/**
* File
*
* @var string database Path to the database file
*/
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'example.baza';
/**
* Constructor
*
* Initialize the database
*
* @return void
*/
public function __construct()
{
}
}

View File

@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
namespace mirzaev\luchikki\models\enumerations;
/**
* Language
*
* Types of languages by ISO 639-1 standart
*
* @package mirzaev\luchikki\models\enumerations
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
* @author mirzaev <mail@domain.zone>
*/
enum language
{
case en;
case ru;
/**
* Label
*
* Initialize label of the language
*
* @param language|null language Language into which to translate
*
* @return string Translated label of the language
*/
public function label(?language $language = language::en): string
{
// Exit (success)
return match ($this) {
language::en => match ($language) {
language::en => 'English',
language::ru => 'Английский'
},
language::ru => match ($language) {
language::en => 'Russian',
language::ru => 'Русский'
}
};
}
/**
* Flag
*
* Initialize the flag emoji of the language
*
* @return string The flag emoji of the language
*/
public function flag(): string
{
// Exit (success)
return match ($this) {
language::en => '🇺🇸',
language::ru => '🇷🇺'
};
}
}

View File

@@ -0,0 +1,67 @@
<?php
declare(strict_types=1);
namespace mirzaev\luchikki\models\traits;
// Built-in libraries
use exception;
/**
* Files
*
* Trait with files handlers
*
* @method static void delete(string $directory, array &$errors)
*
* @package mirzaev\luchikki\models\traits
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
* @author mirzaev <mail@domain.zone>
*/
trait files
{
/**
* Delete
*
* Delete files recursively
*
* @param string $directory Directory
* @param array &$errors Registry of errors
*
* @return void
*/
private static function delete(string $directory, array &$errors = []): void
{
try {
if (file_exists($directory)) {
// Directory exists
// Deleting descendant files and directories (enter to the recursion)
foreach (scandir($directory) as $file) {
if ($file === '.' || $file === '..') continue;
else if (is_dir("$directory/$file")) static::delete("$directory/$file", $errors);
else unlink("$directory/$file");
}
// Deleting the directory
rmdir($directory);
// Exit (success)
return;
} else throw new exception('Directory does not exist');
} catch (exception $e) {
// Writing to the registry of errors
$errors[] = [
'text' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'stack' => $e->getTrace()
];
}
// Exit (fail)
return;
}
}